Field Notes

Running long jobs inside tmux

June 3, 2025

If you start a long command in an SSH session and the connection drops, the command usually dies with it. A terminal multiplexer keeps the shell alive on the server, independent of your connection.

The basic loop

tmux new -s work        # start a named session
# ... run your long command ...
# press Ctrl-b, then d   to detach

tmux ls                 # list sessions
tmux attach -t work     # come back later

After detaching you can close the laptop. The job keeps running, and when you attach again you see everything it printed in the meantime.

A few habits

Alternative

For a one-off command that needs no interaction, nohup command & with output redirected to a file is enough. I reach for tmux when I want to look at the job again.

← All notes