running long jobs using tmux

For the purpose of running long jobs, the tmux command is very useful.

Basically, it allows you to start a tmux session, run something in the session, then detatch from the session, 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.

For a full rundown on tmux and how it will help you reduce the number of terminals you use please see the tmux help page.

First 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 using one of the two commands

tmux detach
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 the following command to list all runing sessions:

tmux ls

Next, attach to your desired session:

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. For more info on tmux please look here.

Back to SwatCS Help Docs