Wednesday, December 22, 2010

Using screen command in linux

The 'screen' command creates in a console session, the equivalent of windows in a GUI-based desktop. These 'screen's persist even after logout. You can ssh into a remote machine, open a 'screen', start your job, detach the screen, and logout. You can ssh back later, reattach the screen and check how the job is going.

screen -R myjob1 - opens a new screen myjob1 (like opening a new window)
Ctrl+a followed by d - detaches screen, and goes back to main session (like minimizing all windows and going to the desktop)
screen -R myjob1 - reopens the screen myjob1 (since it already exists)
Ctrl+a followed by d - detaches screen
screen -R myjob2 - opens a second screen myjob2
Ctrl+a followed by d - detaches the second screen
screen -R - lists screens available (in this case - myjob1 and myjob2)
screen -R myjob1 - attaches that screen
Ctrl+d - terminates the screen

No comments:

Post a Comment