Using the 'screen' Utility

screen is a Linux utility that can be used to run specific commands e.g. in an SSH remote session. Even if the SSH session is to be closed before the command has terminated, the screen session can be detached and keeps running in the background. Whenever a new SSH session has been established to the remote machine you can re-attach to a running screen session and see how execution of the started program continues, and even de-attach again, if required.

Start a program in a screen session:

screen my_program

Detach from the running screen session:

(Press Ctrl-A+D)

List running screen sessions:

martin@pc-martin:~> screen -ls
There is a screen on:
        26366.pts-0.pc-martin  (Detached)
1 Socket in /run/uscreens/S-martin.

Re-attach to a running screen session:

screen -r 26366.pts-0.pc-martin

Sessions are closed automatically when the program running in the session terminates.

Martin Burnicki martin.burnicki@meinberg.de 2018-01-19

  • miscellaneous_tips/02_linux/using_the_screen_utility.txt
  • Zuletzt geändert: 2021-08-12 09:47
  • von martin