Detach and Reattach Console Sessions
Novell Cool Solutions: Tip
By Scott M. Morris
Digg This -
Posted: 7 Nov 2005
- SUSE Linux 10
- SUSE Linux Professional
- Novell Linux Desktop
- SUSE Linux Enterprise Server
PROBLEM: I need to run a console command, detach from it, and then re-attach from a different location.
DESCRIPTION: Sometimes, I have a process that I need to start from work. Since it is a command-line process, if I close the terminal, the process stops. This is true even if it is executed in the background. I need it to continue running so that when I go home, I can ssh back into the machine and reattach to the process.
SOLUTION: This is possible with a program called screen. Ensure that you have this program installed. Then, open a terminal window and type in screen and press ENTER. You may see a screenful of information; just press ENTER. You should then be taken back to a command prompt.
Now, let's type in a command that will keep running when we detach from it. top will work just fine for this exercise. Type in top and press ENTER. You should see the normal output of this program.
Next, let's detach from the process by pressing CTRL+A and then CTRL+D in quick succession. You should see a [detached] message somewhere on the bottom of your terminal screen. The session is now detached.
To reattach the session, type in 'screen -r' without the quotes and press ENTER. You will be reattached to the screen.
Combined with the remote administration power of ssh, this concept will be very useful to system administrators.
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com