Use Screen to Run Long Processes
Tech TipScreen is a Linux utility that allows you to run multiple terminals all within a single terminal window manager. It can be used for many things and greatly increases workflow. Screen enables you to run your long scripts/processes within a screen session.
If you want to execute a script that generally takes a very long time to complete, it can be beneficial to run that script inside of a screen session. That way, if you lose your SSH connection, your script will keep running.
To start a screen, you can simply run the command ‘screen’. This places you into a new terminal window. From there, you can execute bash commands in the usual way. Once you have started your process, you can disconnect from your screen with the key combo: ctrl-a + d
This will take you back to your original SSH terminal session. To rejoin your screen, you can use the command ‘screen -r’. Once you are back in your screen session, you will see that your process has been running in your absence. This is a great way to ensure that your processes finish even if you lose your connection.
There are a multitude of uses for the Linux screen application, and all Linux users should become familiar with it. For a full list of screen commands, type ‘man screen’ while in a terminal.