The screen utility provides a way to run a command on a Linux system, detach from it, and then reattach later. This is particularly handy if you have a long-running process that you want to keep running even after you log out and still have the ability to reattach to it later and/or from another location. If is also useful if you have an unstable ssh login connection and allows you to reconnect to the same session if you get disconnected.
This is general information about using screen that applies to just about every Linux system, not just those in the School of Informatics and Computing.
Basic Screen Usage
There are many good tutorials available on the web describing the use of screen. There is also detailed information in the screen man page, which you can view by running man screen. However, much of this information can be rather daunting given the sheer number of command line arguments and key bindings. The purpose of this page if to give you the bare minimum of information needed to get started with screen.
Here are the steps you can follow to run a process in screen, detach from the terminal, and then reattach.
- From the command prompt, just run screen. This will give you a new subshell.
- Run your desired program
- Detatch from the screen session using the key sequence Ctrl-a Ctrl-d (note that all screen key bindings start with Ctrl-a). This will drop you back to your original shell and display a message "[detached]", indicating that the screen session is still running.
- You can then list the available screen sessions by running "screen -list"
- You can reattach to this screen session by running "screen -r". Once reattached, you will be able to take off where you left off and see any output that was printed to the screen during the time that you were detached. If you have multiple screen sessions, then you can specify the tty name (as displayed by screen -list) as an argument to screen -r to attach to a particular session.
If you are using screen on the available SoIC Unified Linux Systems that are using the Unified Workstation Configuration you will need to take special care when using screen to keep your kerberos credentials alive. For example, this is necessary if you are running screen on a workstation in LH035 but not if you are using a server like silo, tank, or hulk.
Please see the Running Persistent Remote Processes section of the KB article Understanding Linux Kerberos Issues for details on how you can keep your kerberos credentials alive in your screen session. Failure to follow the procedure detailed in that KB page will result in your screen session losing access to your networked home directory. When this happens, it can result in excessive load being put on the home directory file server and it may be necessary for systems staff to kill your screen session.