Use screen to prevent "Broken Pipe" messages and terminal session timeouts
Why?
When connecting to our systems (head, headnode7, lmm, etc.) via PuTTY, or terminal in mac when there is a disruption in the ssh connection, you will see a "Broken Pipe" error and loose access to any programs that were running, without being able to recover them. Screen and tmux allow you to "detatch" a session (i.e. keep it running in the background), and move on to another task in the same terminal window, or disconnect from the machine.
Basic Linux Screen Usage
After connecting to a machine from PuTTY, terminal, etc., type
Code Block language bash screen
- Run the desired program
- Use the key sequence Ctrl-a + Ctrl-d to detach from the screen session, this will keep it running in the background
To see a list of active screen sessions, type
Code Block language bash screen -ls
Reattach to the screen session by typing
Code Block language bash screen -r [your session id here]
There are many useful tutorials for using screen to preserve terminal sessions, here is one: https://linuxize.com/post/how-to-use-linux-screen/#starting-linux-screen
Basic tmux usage
After connecting to a machine from PuTTY, terminal, etc., type
Code Block language bash tmux
- Run the desired program
- Use the key sequence Ctrl+b d to detatch the session
To see a list of active tmux sessions
Code Block tmux -ls
To reattach a tmux session type
Code Block language bash tmux attach-session -t [your session id here]
...