GNU Screen
screen is a terminal multiplexer that allows you to start a terminal session and then "detach" from it. This is essential for HPC work because it allows long-running processes to continue running even if your SSH connection drops.
⚠ Critical: Login Nodes and Session Binding
Screen sessions are tied to the specific login node where you started them (e.g., scu-login01 vs. scu-login02). If you reconnect to the cluster and land on a different login node, screen -ls will show nothing. Always check your node name with hostname before detaching, and SSH directly to that exact node to reattach. Furthermore, running heavy resource-consuming jobs directly in screen on a login node violates HPC policy; always spawn an interactive compute node session inside screen using SLURM (detailed below).
Start a Session
Give your session a name so you can find it later:
Your terminal will clear. You're now inside a session that keeps running on the server, even if you disconnect.
Optional: Save Output to a Log
To keep a record of everything shown in the session, add -L:
The log is saved as screenlog.0 in the directory where you started screen. New sessions started in the same directory add to the same file.
-L for commands that show a live progress bar (such as rsync --progress or rclone -P). The log will fill up with progress updates.The Control Sequence & Shortcuts
Most screen commands start with the escape sequence: Ctrl + A. Note that Screen commands are case-sensitive (e.g., lowercase d detaches, while uppercase D behaves differently).
| Action | Key Command |
|---|---|
| Detach (Leave session running in background) | Ctrl + A then d |
| Create New Window | Ctrl + A then c |
| Next Window | Ctrl + A then n |
| Kill Current Window | Ctrl + A then k |
Scroll / Copy Mode (Review output history; press Esc to exit) | Ctrl + A then [ |
| Send Ctrl+A to Bash (Jump to start of command line) | Ctrl + A then a |
| Help Menu (List all shortcuts) | Ctrl + A then ? |
Managing and Ending Sessions
If you have detached from a session, you can resume or clean it up using these commands:
List Active Sessions
Reattach to a Session
How to End / Clean Up Sessions
To prevent abandoned sessions from piling up on login nodes, always terminate them when finished:
- From inside the active session: Type
exituntil the screen terminates. - From outside the session: Run
screen -X -S session_name quit
(attached) because your previous SSH connection dropped abruptly without letting you detach cleanly, use screen -d -r session_name to force-detach it from the ghost session and reattach locally.Example Workflow: Cloud Data Transfer
To comply with login node policies, heavy workloads or transfers should run inside an interactive compute node allocation spawned within Screen:
screen -L -S cloud_sync
# 2. Request an interactive compute node via SLURM
srun --pty bash -i
# 3. Run your data transfer command (e.g., AWS S3 sync or Rclone)
aws s3 sync s3://my-bucket/data /scratch/user/data/
# 4. Detach safely (Ctrl + A then d). You can close your laptop.
# Note: If your srun time limit expires, work inside srun stops,
# but your screen session on the login node will remain active.