Introduction
The Screen utility is a very helpful tool that allows you to run tasks in a session which you are able to detach from without interrupting said running task. This utility is helpful when executing long-running tasks such as backups, restores or any other task that may not be interrupted but has the potential to run for a while.
The benefit of this is that if you lose SSH access for any reason to the server, your task will not be interrupted as it will continue to run in the session you created. This allows you to detach from the screen and perform other tasks or simply exit completely and return to check on the task.
Procedure
Installation
To install the "screen" utility, you'll use your operating system's package manager.
On Enterprise Linux systems:
yum install screen
On Ubuntu-based systems:
apt install screen
Usage
To begin using this tool, start by specifying a name for the session:
screen -S $SESSION_NAME
Once inside the session, you may run any tasks or commands of your choice and you may detach from the session to leave the task running. To do so, press the following key combination:
[CTRL]+[A]+[D]
To view the available screens:
screen -ls
To reattach to a screen session:
screen -r $SESSION_NAME
For more details and advanced usage of screen, please review the manual page for this utility.