Working With an Unstable Internet Connection
If you are working with an unstable internet connection via ssh and you don’t want to lose your progress every time you disconnect, the screen
command allows you to run a background session that you can reconnect to later.
Establishing a ‘screen’ session
Screen enables your login process and connected processes to remain running if/while your ssh connection is interrupted. Its pretty easy:
- Start a command-line shell on one of Monsoon’s login nodes
- Start a screen session by running the
screen
command - Initiate any programs/processes
If desired, you now may disconnect from Monsoon while allowing your programs to continue without being actively connected. Here’s how:
- Simply close your SSH client/window
OR: - Exit your active
screen
gracefully with this key-sequence:
ctrl+a; then release both keys; then hit d(The ctrl+a, d sequence detaches from the session. The ctrl+a keystroke itself tellsscreen
to listen for subsequent key-commands.)
Now that you are disconnected from screen, your processes will continue to run to completion.
Reconnecting to a ‘screen’ session
To reconnect to screen to monitor or end your programs do the following.
- Ensure you are logged in to the same system
(e.g.: wind, rain, dtn1, ondemand) - Run
screen -r
The screen -r
command will resume an existing screen session. If there are multiple sessions you will have to be specific:
- Run
screen -ls
to list thescreen
sessions.
[abc123@wind ~ ]$ screen -ls
There are screens on:
1144795.pts-0.wind (Detached)
1944762.pts-0.wind (Detached)
2463388.pts-7.wind (Detached)
3 Sockets in /run/screen/S-abc123. - Then run
screen -r <number>
to resume.
Example:screen -r 1144795