I have connected to my server via SSH and created a process, but suddenly my internet connection got disconnected. I know that the process is going on, but how can restore previous session to see the progress of it?

7 Answers 7


As suggested above, in the future you can use screen to prevent such thing. A short explanation on how to use screen:

  1. screen -S compiling_stuff
  2. Do stuff here. e.g ./configure
  3. If connection is closed for some reason you can reconnect to the server and issue screen -r comp
  4. You can detach the screen session yourself too by pressing CTRL+A+D

Good luck


screen is the best to start a command in a terminal that will be kept when you disconnect from it (either on purpose, ctrl+a d, or because connection dies, etc).

HOWEVER you CAN re-attach a running process (ex: the shell of your running session, if still running) to your current terminal (ie, re-attach stdin, stdout, keyboard, but also make the new terminal the controlling terminal for that process) using: reptyr

For the best of both worlds: install screen, start it, and then re-attach that process in that screen sessions with reptyr ^^

  • Oliver, how is it possible to re-attach to running process? Could you gimme a hint please?
    – archer
    Jan 11, 2013 at 15:12
  • @archer : hint : follow the link ^^ (end of my 2nd paragraph) Jan 11, 2013 at 17:02
  • @archer : but screen is simpler: once runnign in screen, ctrl+a d : detach from screen (and go home). then to re-attach to screen: "screen -r" (or a more complex way, if things get stuck). To differentiate amongst many screen sessions, give them a name. Jan 11, 2013 at 17:06

You can't. In the future, you can prevent something like this with using screen or tmux, which where created to allow to reconnect to a session after a disconnect.


Just thought I would mention http://mosh.mit.edu/

Remote terminal application that allows roaming, supports intermittent connectivity, and provides intelligent local echo and line editing of user keystrokes.

Mosh is a replacement for SSH. It's more robust and responsive, especially over Wi-Fi, cellular, and long-distance links.

  • +1 for the heads up, I never heard of that tool before! Jan 21, 2013 at 13:30

Use screen via ssh to reconnect later to your session.

As far as I know there is no way to reconnect to a closed ssh-session.


I can recommend Byobu:

Byobu is an enhancement for the terminal multiplexers GNU Screen or tmux that can be used to provide on screen notification or status as well as tabbed multi window management. It is aimed at providing a better user experience for terminal sessions when connecting to remote servers.


I would recommend to use tmux:

You can restore tmux session via tmux attach.

tmux is a software application that can be used to multiplex several virtual consoles, allowing a user to access multiple separate terminal sessions inside a single terminal window or remote terminal session. It is useful for dealing with multiple programs from a command line interface, and for separating programs from the Unix shell that started the program.[1] It provides many of the same functions as GNU Screen, but is distributed under a BSD license.

You must log in to answer this question.

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