Shutting down PC without killing SSH sessions

It sounds like you are running the screen session on your laptop. Then sshing from that screen session to the remote host(s). Shutting down the laptop will kill the local screen process, which in turn kills the ssh session.

What you want to do is ssh from your laptop to the remote host(s). Then start a screen session on the remote host. When you laptop is turned off, the ssh session will die, but the remote screen session will persist.

The next time you log in to the remote system, you can re-attach to the screen session with "screen -r" or if you have multiple screen sessions "screen -r < pid >".

Note: if you forgot to detach from the remote screen session before ssh is killed, the screen session may think it is still attached. In this case, you'll need to do "screen -dr < pid >" to detach the session first.


You can use nohup to start a process that shall continue to run after you have logged out from a machine. That might be what you are looking for.


If you detatch the remote session in screen, you can safely shut down your laptop.


The point of screen is to run it on the server and detach with CTRL + A + D.


Use nohup. Another choice to use VNC. Create VNC session on the server. Then connect to it whenever you work on. (More useful when the long process is using some GUI - an IDE for example)