# 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.

### Starting a screen session

Screen enables your login process and connected processes to remain running if/while your ssh connection is interrupted. Its pretty easy:

1. Start a command-line shell on one of Monsoon's login nodes
2. Start a screen session by running the `screen` command
3. 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:

1. Simply close your SSH client/window  
   OR:
2. Exit your active `screen` gracefully with this key-sequence:  
   <kbd class="key-control">Ctrl</kbd>\+<kbd class="key-a">A</kbd>; *then release both keys*; *then hit* <kbd class="key-d">D</kbd> (The <kbd class="key-control">Ctrl</kbd>\+<kbd class="key-a">A</kbd> <kbd class="key-d">D</kbd> sequence detaches from the session. The <kbd class="key-control">Ctrl</kbd>\+<kbd class="key-a">A</kbd> keystroke itself tells `screen` 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.

1. Ensure you are logged in to the same system  
   (e.g.: `wind`, `rain`, `dtn1`, `ondemand`)
2. Run `screen -r`

The `screen -r` command will resume an existing screen session. If there are multiple sessions you will have to be specific:

1. Run `screen -ls` to list the `screen` sessions.

```bash
[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.
```

1. Then run `screen -r <number>` to resume.

```bash
[abc123@wind ~ ]$ screen -r 1144795
```
