1. Home
  2. NI Cluster
  3. Maintaining Connections

Maintaining Connections

When uses log onto remote severs as they do with the MIND cluster, often there are instances where they would like to logoff but still maintain running processes. The use of the following tools will allows users to maintain their sessions ( collections of windows ) and processes after they disconnect from the cluster.

Screen and tmux

Screen and tmux tools works on UNIX based operating systems such as Linux and MacOS. They allow users to use multiple windows and provides a way for a user to detach from a terminal session and then reattach to it at a later time. To be able to do this, the user has to be in a screen or tmux session. ( Just using the terminal won’t allow you do this.) Whenever you are detached from the terminal session, the processes are killed but these tools allow the processes to continue when detached. You can reattach to the particular session at a later time and your active terminals will be as you left them.

To start screen, type screen at the command prompt. Your original session will be detached and you will be brought to a new window.

This shows details such as screen geometry and character set. The important part is that 2(bash) at the end. The 2 is the number of the currently displayed terminal window, and bash is the shell. Users can press crtl+A, then the number of the screen to which they wish to attach, or press Ctrl+A followed by a D to get a list of terminal windows available.

Each screen can run any program contained on the cluster.

To detach a screen and come back to it later…use the system above to start a window with Matlab or another program. Then issue the key Ctrl+A followed by a D. This will drop the user back to the bash prompt after detaching any session. The user may logout at this point.

To reattach an existing session, login to the command prompt and type screen -ls. This will list all detached sessions.

[dpane@psych-o ~]$ screen -ls
There is a screen on:
    8673.pts-6.psych-o    (Detached)
1 Socket in /var/run/screen/S-dpane.

To reattach to that one session, I would type this at the bash prompt:

[dpane@psych-o ~]$ screen -r 8673.pts-6.psych-o

From there, it will return the session to the current login.

Screen Cheat Sheet

  • ctrl a c -> cre­ate new win­dow
  • ctrl a A -> set win­dow name
  • ctrl a w -> show all win­dow
  • ctrl a 1|2|3|… -> switch to win­dow n
  • ctrl a ” -> choose win­dow
  • ctrl a ctrl a -> switch between win­dow
  • ctrl a d -> detach win­dow
  • ctrl a ? -> help
  • ctrl a [ -> start copy, move cur­sor to the copy loca­tion, press ENTER, select the chars, press ENTER to copy the selected char­ac­ters to the buffer
  • ctrl a ] -> paste from buffer
Starting screen
  • screen –DR -> list of detached screen
  • screen –r PID -> attach detached screen ses­sion
  • screen –dmS MySes­sion -> start a detached screen ses­sion
  • screen –r MySes­sion -> attach screen ses­sion with name MySession
  • ctrl a S -> cre­ate split screen
  • ctrl a TAB -> switch between split screens
  • ctrl a Q -> Kill all regions but the cur­rent one.
  • ctrl a X -> remove active win­dow from split screen
  • ctrl a O -> logout active win­dow (dis­able out­put)
  • ctrl a I -> login active win­dow (enable output)
Updated on January 24, 2020

Was this article helpful?

Related Articles

Need Help?
Can't find the answer you're looking for?
Contact NI Support