Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Action

Use screen command to prevent "Broken Pipe" messages and terminal session timeouts

Info
titleWhy?
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 and let your code keep running

Instructions

Basic Linux Screen Usage

  1. After connecting to a machine from PuTTY, terminal, etc., type

    Code Block
    languagebash
    screen
  2. Run the desired program
  3. Use the key sequence ctrl ad to detach from the screen session, this will keep it running in the background and return to your main shell

    1. Note, if you do not detach the session, you can restore if the connection drops by reconnecting and running screen -r
  4. To see a list of active screen sessions, type

    Code Block
    languagebash
    screen -ls
  5. Reattach to the screen session by typing

    Code Block
    languagebash
    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

  1. After connecting to a machine from PuTTY, terminal, etc., type 

    Code Block
    languagebash
    tmux
  2. Run the desired program
  3. Use the key sequence Ctrl+b d to detatch the session
  4. To see a list of active tmux sessions

    Code Block
    tmux -ls
  5. To reattach a tmux  session type

    Code Block
    languagebash
    tmux attach-session -t [your session id here]

There are many useful tutorials for using tmux to preserve terminal sessions, here is one: https://linuxize.com/post/getting-started-with-tmux/#starting-your-first-tmux-session


Include Page
Footer
Footer