This is an old revision of the document!
Geeky notes on how to survive the endless battle against man and machine.
Screen is the best sysadmin and cluster user companion. It does a magical thing: if you disconnect abruptly from a server, it will keep everything running as is you've never disconnected. Think of it as an open window to your work on a remote machine, to which only you can have access.
To give an idea of what
screen does, follow this simple tutorial in which we will be using the
top utility that shows processes running on a machine. The tutorial shows how, if you start top in a screen session and you disconnect from a server, the top program is still running on the remote machine.
Please read tips at the end on how to use copy mode and move in the open window.
[pflorido@n12 pp]$ screen
An intro page will appear where you have to press enter or space. At this point you are in a virtual shell running on the server, independent from the ssh connection. If connection drops by during this time you don't loose your session.
[pflorido@n12 pp]$ top
A lot of info about running processes will fill the terminal.
The screen session will be detached. you'll see a message like:
and you will be sent back to the shell where you wrote
With the command
[pflorido@n12 pp]$ screen -list
You'll see a list of running detached or attached screens, like this:
There is a screen on: 20440.pts-1.n12 (Detached) 1 Socket in /var/run/screen/S-pflorido.
[pflorido@n12 pp]$ screen -DR 20440.pts-1.n12
You should now see the running processes as if top command was never stopped. In fact it had never stopped!
q to exit it and keep working on the same screen shell.
You can try
screen effectiveness this way:
screen -list: the screen session is still there!!
Inside a screen session, interaction with the shell changes. In particular, to scroll up and down you should use the combination:
Ctrl a ESCto enter copy mode. Then you can move the cursor up and down in the screen session.
Ctrl a ?will give you a list of commands
man screenwill give you more info.
Ctrl a c
Ctrl a pprevious
Ctrl a nnext