Home » Questions » Computers [ Ask a new question ]

Linux process to background - relogin - how to bring process back to foreground?

Linux process to background - relogin - how to bring process back to foreground?

I start a process, put it in the background running, then log out, then log in again, and want to bring the process to front again. I've looked in "ps aux" for the PID, but it won't be put in the foreground with "fg ###". What's the correct way?

Asked by: Guest | Views: 34
Total answers/comments: 1
Guest [Entry]

"The most common way to accomplish this is probably with GNU Screen.

Screen is a full-screen window manager
that multiplexes a physical terminal
between several processes, typically
interactive shells.

Basically you will:

Make sure screen is installed. Typically this is the package 'screen' on most Linux distributions. It is installed by default on Mac OS X.
Execute screen

Run the program you wish to 'background'. For example, I start tailing a log file:

Press Ctl-a, d to detach screen.
Log out, do other things, whatever you like. Here, I'll send a message to the log.

When you log in again, type screen -r to reattach the session you were running before. Here you can see the message I sent to the log (and an earlier test, too).

Screen is considered by many to be a power user tool on Linux/Unix, and I'm inclined to agree!

For more information about screen, see its home page, or this in depth article from Ars Technica."