Saturday, December 13, 2008

screen

when to I use screen :

* When "nohup" is just not enough
* When the power goes off and you are left in the middle of nowhere
* When I need to log on to 10 different terminals each day
* When I do not want to enter 10 different username passwords each day

"screen" is a terrific unix utility that allows you to start a terminal without having to worry about you job being interreputed mid-way. It is better than nohup in that respect nohup only allows unix commands to be started in a "nohup" fashion. If for instance you are working with an interactive program like sqlplus and your internet connection happen to break, you will loose your context and any transactions that you were working on.

It essentially allows you following :
* Multiple sessions in a single ssh window (screen multiplexing)
* Ability to "resume" a session in the state you left it - irrespective of power outage, internet connection termination etc

Here is how you use it :

1. Make sure it is installed on your system by typing "screen --help"
2. If it is not installed, you can install it by "yum install screen" on a fedora box.
3. start a screen session by typing "screen" and you should be in a screen session.
4. If you are disconnected or closed the terminal, type "screen -r -d" to reattach to the session

Here are some of the short-cuts available (All after CTRL+A)

c : creates a new
n : next screen window
p : previous screen window
a : toggle between two screen windows
[0-9] : Go to a specific screen window identified by a number
A : Set the name of a screen window
" : List all the existing screen
ESC : Scroll up or down on a screen

No comments: