Today we have a guide to ‘terminal multiplexing’ including suggestions on how to use it on computer clusters such as ShARC and Bessemer.
If the answer to any of these is “yes” then terminal multiplexing may help!
First, we need to delve a little deeper into some of the problems we are trying to solve.
(Skip over this section if you want!)
Every process (bar the systemd
process or init
process with a
process ID of 1) has a parent process. If a process is sent a signal
telling it to cleanly terminate (or ‘hang
up’) then typically its child
processes will be told to do the same.
When you SSH to a remote machine, the SSH service on that machine creates a shell for you within which you can run commands.
To illustrate, here I logged into a server and used the pstree
program
to view the tree of child-parent relationships between processes. Notice
in the excerpt shown below that the SSH service (sshd
) has spawned a
(bash) shell process for my SSH session, which in turn has spawned my
pstree
process: :
[will@acai ~]$ ssh sharc
...
[will@sharc-login1 ~]$ pstree -a
systemd --switched-root --system --deserialize 21
...
├─sshd -D
│ └─sshd
│ └─sshd
│ └─bash
│ └─pstree -a
...
So if the SSH service decides that your connection has timed out then it
will send a signal to bash
process were to die then any child
processes started by that bash
process would also die.
If the remote servers you work with are primarily High-Performance Computing (HPC) clusters running scheduling software such as Grid Engine then you have a simple, robust way of ensuring that the sucess of your processes doesn’t depend on the reliability of your connection to the clusters: submit your work to the scheduler as batch jobs. There are many other benefits to submitting batch jobs over using interactive sessions when using such clusters but we won’t go into those here.
However, what do you do when there is no HPC-style scheduling software availble?
Neither of these allow you to easily return to interactive sessions though. For that we need terminal multiplexers.
Terminal Multiplexer programs like GNU Screen and tmux solve this problem by:
Here we look at demonstrating the above using tmux. I recommend tmux over GNU Screen as the documentation is clearer and it makes fewer references to legacy infrastructure. Plus, it is easier to google for it! However, it may use more memory (true for older versions).
Let’s create and attach to a new tmux session, start a long-running command in it then detach and reattach to the session:
For queries relating to collaborating with the RSE team on projects: rse@sheffield.ac.uk
Information and access to JADE II and Bede.
Join our mailing list so as to be notified when we advertise talks and workshops by subscribing to this Google Group.
Queries regarding free research computing support/guidance should be raised via our Code clinic or directed to the University IT helpdesk.