Table of Contents
CLUSTER MANUAL
Interactive jobs
What's on this page:
- Starting an interactive job
- Keep interactive jobs alive
1. Starting an interactive job
You can run an interactive job like this:
$ srun --nodes=1 --ntasks-per-node=1 --time=01:00:00 --pty bash -i
Here we ask for a single core on one interactive node for one hour with the default amount of memory. The command prompt will appear as soon as the job starts.
This is how it looks once the interactive job starts:
srun: job 12345 queued and waiting for resources srun: job 12345 has been allocated resources
Exit the bash shell to end the job. If you exceed the time or memory limits the job will also abort.
Interactive jobs have the same policies as normal batch jobs, there are no extra restrictions. You should be aware that you might be sharing the node with other users, so play nice.
2. Keeping interactive jobs alive
Interactive jobs die when you disconnect from the login node either by choice or by internet connection problems. To keep a job alive, you can use a terminal multiplexer like tmux.
tmux allows you to run processes as usual in your standard bash shell. You start tmux on the login node before you get an interactive slurm session with srun and then do all the work in it.
In case of a disconnect you simply reconnect to the login node and attach to the tmux session again by typing:
tmux attach
or in case you have multiple session running:
tmux list-session tmux attach -t SESSION_NUMBER
As long as the tmux session is not closed or terminated (e.g. by a server restart) your session should continue. One problem with tmux is that the tmux session is bound to the particular login server you get connected to. So, if you start a tmux session on a particular login node and next time you get randomly connected to a different login node, you first have to connect to back to the original login node. Given that psychp01 has currently only one node, this is not an issue for us now.
To log out a tmux session without closing it you have to press CTRL-B (that is, the Ctrl key and simultaneously “b”, which is the standard tmux prefix) and then “d” (without the quotation marks). To close a session just close the bash session with either CRTL-D or type exit.
You can get a list of all tmux commands by CTRL-B and the ? (question mark). See also this page for a short tutorial of tmux. Otherwise working inside of a tmux session is almost the same as a normal bash session.
Discussion