Linux: screen utility
If you need to run a long running task on a remote machine and don’t want to worry about the connection dropping, you can use the screen utility. The screen utility allows us to detach from that session and resume whenever we need to.
Start a new screen by typing in screen -S {name of the session}. In our case we’re calling it “my-session”.
That then takes you to a new session. We can then detach from the screen by pressing control + a + d all at the same time or screen -d.
This removes us from that session but keeps whatever was running in that session intact and undisturbed. So we can exit the ssh session we’re in and there would be no issues. We could then ssh back into the server and resume the screen session by typing screen -R {name of the session} and in our case the command would be screen -R my-session. Very useful for long running processes that we don’t want to get interrupted by a connection dropping. See the “man pages” here
Let’s see it in action: