Screen
Table of Contents
Screen, a Bioinformaticians Best Friend
Screen is very likely the best way to keep things running in the terminal servers that you connect to. While dropping things into the background and booting them off with nohup so that they ignore the Sig Hup signal is an option, it isn’t as clean as screen and it isn’t so easy to just pick up where you left off, for instance, if you had something open in a text editor.
At first Screen can be a bit intimidating, to keep track of all this virtual terminals, but we only really need a few Screen commands to make do.
screen
This will create and enter a new screen.
press ctrl+a, then press d
This leaves a running screen.
screen -ls
This lists all screens that are running, we should see the one we just left:
There are screens on:
3211.pts-0.crimv3srv007 (Detached)
1 Sockets in /var/run/screen/S-QCRI\kkunji.
To reconnect to that screen, or any other in the list, we can use the screen’s id on the left, so in this case:
screen -rd 3211
Finally, if you’re in a screen and you don’t want to leave it running with the
ctrl+a, then d method, then you can use the exit
command from that screen.
It will then be closed and will not be available when you check with screen -ls
.
That’s all it takes to get by with screen and make it useful. Screen has quite
a few other features worth exploring, but this is all we need for basic
management in order to avoid losing work to ssh timeouts. When a timeout occurs
and screen is running, you will be able to get back to that screen after logging
in again by using screen -ls
to find it and screen -rd
to rejoin it even if
it thinks you were still attached.