I'm running an install task on Pi and my connection to pi dropped. How can I relogin to previous session so can view install progress.
In future I should log output to file (so can view progress by opening file if similar situation occurs)?
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It only takes a minute to sign up.
Sign up to join this communityI'm running an install task on Pi and my connection to pi dropped. How can I relogin to previous session so can view install progress.
In future I should log output to file (so can view progress by opening file if similar situation occurs)?
Try using the "screen" program. Install it with:
sudo apt-get install screen
Now after you ssh into the pi, type screen
and press enter. You are now inside a "screen". You can go about your work like normal.
To disconnect from the screen, simply type. "ctrl-a, d". To be clear, this means first hit ctrl
and a
at the same time, then release both keys, then press d
.
To resume after your ssh session has dropped, simply ssh back in, and type screen -r
. If you have more than one screen session running, you can type screen -ls
to see all of them, and then connect to a specific one with screen -r 1234
where 1234 is the first number listed on the line.
Two cool tools simplify your life with respect to the issue of reconnecting to a session lost during a connection drop: gnu screen
and tmux
. Those two also offer nice and useful features that come in handy and that is the multiplexing of several virtual consoles. This is especially helpful to control multiple programs on the command line interface from just a single terminal or via one remote terminal session.
To add to portforwardpodcast's answer just another little advice to aid usability. Invoke screen -S apt
to create a session called "apt" (or whatever you like). This way the session can be easily resumed by screen -r apt
without the need to list all the existing sessions first.
screen
ortmux
.