This is not a happy situation to begin with, but what if you have to? Someone has to do the dirty job. In order for you to not have your laptop connected to the production environment for 10 hours just to run a job, you need:
Steps
So, for our specific purpose, to keep it short:
- Enter
screen
to enter the screen. - Do the long-running dirty job that you need to do.
- Close the ssh. This will force your job to go into “detached” mode. Aka, it’s running in the background now. Don’t use
exit
to close it, though, or you’ll close yourscreen
, and by extension, end your job. - After 10 hours, ssh back into production, and use
screen -ls
to list all the screens that are in the background. - Use
screen -r 41565
(number will be listed after running the above command) to enter the hidden screen. - Use
exit
to endscreen
.
Alternatively
- If you don’t like numbers, you can also give your
screen
a name withscreen -S fancy-name
and use this name to re-attach back to it. - If you are confused about all the “closing” of windows, you can also explicitly detach your
screen
withctrl + A
then pressd
.