running long jobs using tmux

The tmux command allows you to start a tmux session, run something in the session, then detatch from the session (even log out), and whatever you are running in the session keeps going. You can even log out, go home, log in later, and then reattach to the session to check your progress.

To start a tmux session:


At this point, start your long job:


Or you may want to save the output of your job into an output file:

python3 >> output.txt

Now you can detach from the tmux session

Ctrl-b d

That means hold down Ctrl and hit b, then let up on both and hit d.

You are now detached from the session free to log out.

Later, when you want to re-attach, just log in to the original machine and run:

tmux ls
tmux attach -t (session number)

If you only have one session running it should be:

tmux attach -t 0

When done, you can exit a tmux session with exit

Basics of tmux

tmux is also handy as a tool to multitask with. By default you can split screens horizontally or vertically by doing

Ctrl-b "
Ctrl-b %


To switch between the panes:

Ctrl-b (arrow keys)

You can also zoom in on panes:

Ctrl-b z

Back to SwatCS Help Docs