I have some heavy, long processes running on remote Linux machines. I use my laptop to SSH to these machine and run the processes from my couch.

BUT, when I want to shutdown my laptop, I am in trouble since the remote processes are killed.

I did my research and found out that "screen" is a great solution for me, it is! (As long as I don't SHUTDOWN my laptop). Isn't there a way to "persist" the "screen" sessions so I can shut it down and then re-attach to a session?

migrated from stackoverflow.com Aug 11 '10 at 0:15

This question came from our site for professional and enthusiast programmers.

  • Are you running screen on the remote Linux systems? – Sam Miller Aug 10 '10 at 23:07
  • is it possible to background the processes? – ennuikiller Aug 10 '10 at 23:09

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.

  • 4
    By the way, if I remember correctly, pressing Ctrl+A followed by D when you're in screen will detach the screen session. – David Z Aug 11 '10 at 1:35
  • @David this is correct, you can also just close your terminal or ssh session and the screen will remain open. "screen -raAd" will reattach. – Chris Aug 30 '10 at 12:08
  • How can I start a screen session on the remote host? – stupidity Oct 2 '13 at 11:41

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.

  • For an already-running process, you can do ^Z and then disown to create what I believe is an equivalent effect. disown is a bashism that may or may not be available on other shells. – intuited Aug 11 '10 at 0:22
  • +1 for nohup. The trouble with ^Z is that it pauses the process. There's no way to background a process but keep it running without a hiccup. – detly Aug 11 '10 at 3:55

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

  • Not sure if it's universally obvious that the screen session being detached from must be on the remote server. – intuited Aug 11 '10 at 0:21

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)


If these servers have an ILO/DRAC/Other remote KVM, etc you may be able to connect to the console and interact there. Since the sessions initiated are essentially local, dropping the connection from your laptop won't do a thing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy