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?
As suggested above, in the future you can use screen to prevent such thing. A short explanation on how to use screen:
screen -S compiling_stuff
- Do stuff here. e.g
- If connection is closed for some reason you can reconnect to the server and issue
screen -r comp
- You can detach the screen session yourself too by pressing
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
You can't. In the future, you can prevent something like this with using
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.
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 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. It provides many of the same functions as GNU Screen, but is distributed under a BSD license.