I am using the Screen utility and would like to preserve the session when the machine reboots. If not possible may be you can recommend other alternatives to Screen that would allow to preserve the sessions between reboots.

I am using Ubuntu Server 10.04 (Lucid Lynx) if that matters.

I have several sessions opened via Screen. When the machine reboots all those sessions are lost, and I have to reopen them again. I wanted to find a way to preserve those Screen sessions.

  • what are you trying to to? do you want to preserve the history or everything running in your screen session?
    – Marcel G
    Sep 21, 2010 at 15:55
  • 1
    Wouldn't doing this defeat the purpose of rebooting? Sep 21, 2010 at 19:56
  • what do you mean by 'sessions'? Do you mean that you have ssh connections to other hosts in several screen windows? If that is what you mean, then writing a .screenrc file and specifying the user@host you want to slogin to should do the trick ..., if you have enabled ssh passwordless logins. Then when you start screen, all the ssh connections will automatically start. You could even start it from rc.local (a bit tricky, because you need to start it from su - yourusername), so when you login you can reattach the running screen session. Nov 6, 2010 at 12:02
  • 1
    more importantly, why are you rebooting all the time? Unix servers are not windows servers, they are designed for high up times, machines are known to have uptimes of years (without kernel security patches). If your rebooting due to kernel security patches, then have a look at something like ksplice. Nov 6, 2010 at 12:13

6 Answers 6


First of all, let's clarify a couple of important things:

  1. How many machines are involved? In other words, are you connecting to a remote machine, or is everything on your local machine?
  2. If there is a remote machine involved, which machine is rebooting: is it the server or the client?

If there is one machine involved, or if the server is being rebooted, then you're mostly out of luck.

If you're logging into a remote machine, but need to reboot your local machine, then it's no problem as long as you're running screen on the remote machine instead of your local machine. I realize this is pretty obvious to any experienced (even slightly experienced) user of screen, but I mention it just in case it may be helpful.

Yet another possibility (again, whether this is helpful for you depends on your circumstances) is to run the machine with screen on a VM. Suppose it's a remote physical server and it needs to be rebooted, but it's got a guest OS on (e.g.) VMware. You can suspend the guest OS and start it up again after the hardware reboots. It all depends on why you need to reboot, which wasn't specified, and how much control you have over the machine, and whether you're willing to go to all that trouble.

There's no EASY solution, and it's possible none of the solutions will work for you. But best of luck.

If you're logging into many machines, it might seem like too much of a pain to run screen on all the remote machines separately, and it is. In this case it is useful to have an intermediate machine running screen, which can have many screen windows, each logged into another remote machine. As long as the intermediate machine stays up, you can reboot your own local machine (or pack it up in your bag and take it home for the night, or whatever) and screen keeps running on the intermediate machine. (And obviously if any of the remote machines go down, you lose the connection to that machine, but the rest of your screen sessions are fine.)

But in most likelihood you're referring to either the remote machine or the only machine being rebooted, in which case there's no simple way to do this. CryoPID sounds promising at first, but its web site says it doesn't work for screen.

But there is one other somewhat promising option worth exploring. (Whether it will work for you depends to a large degree exactly what you're trying to do.) Check this out on github.com: https://github.com/skoneka/screen-session/tree/master/ScreenSession/

  • +1 for cryoPID, didn't know about that! Nov 6, 2010 at 13:05
  • ScreenSession looks interesting, from the description of it this is exactly what I wanted
    – Sergey G
    Nov 9, 2010 at 15:06
  • I was just googling this, because i think you can save the sessions. I saw an article before, im sure the same can be found easily, where you can save the sessions before reboot, then repopulate them (i use one jump host server, which i want to reboot) Dec 23, 2019 at 23:53

In some rare circumstances this is possible (see CryoPID or CryoPID2), but in general this is difficult, so cannot be done.

  • The link is broken.
    – kasperd
    Apr 6, 2015 at 21:26

Instead of using screen, use a small Virtualbox VM and work inside that. Then you can just hibernate it, reboot the host, then wake the VM back up (just like closing and reopening the lid of a laptop). SSH connections to remote hosts probably won't persist by this method, I don't think it would be possible to guarantee that.

  • Actually I would like to update my answer to tmux-resurrect
    – Gaius
    Jan 9, 2015 at 16:58
  • tmux-resurrect looks like a very good solution.
    – serv-inc
    Nov 24, 2015 at 9:30
  • Make an answer for tmux-resurrect, then? You can have two different answers to the same question.
    – Mathieu K.
    Oct 28, 2020 at 5:14

You cannot. Certainly not on the same machine


In all of this, Screen itself is pretty marginal. It's not Screen that you want to "save", is it?, but the environments within the various screen sessions, whatever they are.

You seem to be suggesting that saving a Screen session would cover an SSH process inside it and all sorts. What is running inside Screen is none of Screen's business at all, and those are things that would be hard to "save"... whatever that really would mean if implementable.


You can use tmux with tmux-resurrect plugin for preserving the session after reboot

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .