8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23ai | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » Linux » Here

GNU Screen Utility

The GNU screen utility allows us to protect long running processes from being killed by network failures. Screen is a window manager, so it can do a lot more than just the use case described here, including allowing us to run multiple screens and using split screens, but the main thing that is important to me is to protect work from network disconnections.

Related articles.


The installation is really simple.

# yum install -y screen

Basic Usage

The most important use case for me is to create a new screen to do some specific work that absolutely must not fail, even if a network failure occurs. In this case, we are just going to run "top". You don't have to name your session with the "-S" option, but I really would if I were you!

$ screen -S my_important_session
$ top

There are a couple of things that could happen now.

  1. You want to disconnect from the server and leave your PC, without killing the running process.
  2. Your connection to the server dies and you don't want your process to end.

How do you deal with these?

  1. If you want to manually disconnect, just do CRTL+a d (or CTRL+a CTRL+d). Your screen will continue, but you are detached from it.
  2. Pull the plug on your network, wifi or VPN, and you can simulate this type of problem.

When you get back to your system, what do you do?

List the screens that are available.

$ screen -ls
There is a screen on:
        19585.my_important_session      (Detached)
1 Socket in /var/run/screen/S-root.


You can then reattach to the screen and continue your work. You have the choice of using the ID, screen name or the full ID and name.

$ screen -r 19585
$ screen -r my_important_session
$ screen -r 19585.my_important_session

When the work is done you can exit the screen by using exit command, just like you are exiting SSH.

Unnamed Screens

If you don't want to name your screens you don't have to. Just start a new screen with out a name.

$ screen

Detach the screen using CTRL+a CTRL+d, then check the list of screens.

$ screen -ls
There is a screen on:
        19883.pts-0.localhost   (Detached)
1 Socket in /var/run/screen/S-root.


You can then reattach in the same way we saw before.

$ screen -r 19883
$ screen -r pts-0
$ screen -r pts-0.localhost
$ screen -r 19883.pts-0.localhost

What Next

As mentioned previously, the screen utility can do much more than this one use case. If you are interested in using multiple screens, check out the Screen User’s Manual.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.