Screen is a small program in Linux which is useful while running long running tasks, screen keeps a shell active even though network disruptions. In other words, it means that you can start a screen session and then open any number of windows (virtual terminals) inside that session. Processes running in Screen will continue to run when their window is not visible even if you get disconnected. One of the use cases for running screen would be to run scripts, which takes a lot of time to process such that network connection may time out.
The screen package is pre-installed on most Linux distros nowadays. You can check if it is installed on your system by typing:
Command used to activate screen:
Fig: Command to go into screen
This will open a screen session blank screen appears.
Once screen is activated, use it as a normal shell console. For example, execute some Procedure ( exec sp_processinfo(1,’D’) )
Fig: example of running a script while using screen
The user can then close the console and the script will run to completion.
To check on the progress of screen, it can be re-attached to console. The user can user ‘screen –ls’ to see which screen is active and choose which screen to re-attach to check its progress. Reattachment of screen to current console can be done using ‘screen –r <screen number>’
Fig: Command to display list of active screens
Fig: Using screen –r to reattach screen on ‘50444’
User can exit out of screen to regular console by using exit command.
Fig: Quit from screen console
Below are some most common commands for managing Linux Screen Windows:
Ctrl+a c Create a new window (with shell)
Ctrl+a ” List all window
Ctrl+a 0 Switch to window 0 (by number)
Ctrl+a A Rename the current window
Ctrl+a S Split current region horizontally into two regions
Ctrl+a | Split current region vertically into two regions
Ctrl+a tab Switch the input focus to the next region
Ctrl+a Ctrl+a Toggle between the current and previous region
Ctrl+a d The program running in the screen session will continue to run after you detach from the session.
Ctrl+a Q Close all regions but the current one
Ctrl+a X Close the current region