Caution
This article was published more than a year ago, there may have been developments.
Please take this into account.
Today we talk about screen
: a small utility command line for Linux systems.
Screen, quite simply, he's able to multiply the terminals at our disposal, of undock a terminal by its process and maintain active process in the background (by returning the terminal to use).
Screen is particularly useful when it launches a command that requires a response time rather long (such as a backup) be it launched locally or on a remote server. The timeout of the server or the user accidentally kill could lead to an interruption command and frustrate the time spent.
But let's see how it works:
screen | start screen and returns the shell |
screen + comando | start the program “command” inside “screen” |
Once started “screen “ | |
“ctrl+a ” and then “c “ | creates a new terminal |
“ctrl+a ” and then “n “ | skips to the next terminal |
“ctrl+a ” and then “p “ | switches to the previous terminal |
“ctrl+a ” and then “d “ | “unhooks” screen from the session |
Once unhooked from the session can end the SSH tunneling or close the terminal. The program will continue to run in the background.
To retrieve a previous session will take “hang up”:
screen -list | lists all the started sessions |
screen -r | retrieves a previously started session |
Below is one example of the terminal with two sessions “dropped” The screen.
~$ screen -d
There are screens on:
16268.pts-3.joe-desktop (01/12/2019 20:58:09) (Detached)
23799.pts-4.joe-desktop (01/12/2019 16:30:08) (Detached)
There is no screen to be detached.
~$
To “hang up” to a specific session just specify the PID. I our case “screen -r 16268
“.
To clear a screen that is the command: screen -X -S {PID della sessione} kill
.
0 Comments