Posted in Uncategorized

tmux – Keep Jobs Running

tmux – a “terminal multiplexer” – lets you control several windows to the command line from one terminal session. Additionally you can leave tmux and close the terminal – this is very handy, if you have long running programs, and have to leave the office.

So let’s start tmux:

$ tmux

The screen is not very spectacular – you hear a little ping and you see a prompt and a status line.


Now we start a long running job, i.e.:

while true
    sleep 10

Next press Ctrl-B d. Ctrl-B is the “prefix key” and is used to introduce the tmux commands. d is the command to detach from the tmux session.

Now get a cup of tea, go outside or just wait some minutes.

If you come back to the terminal, type

$ tmux ls

This lists all active tmux sessions. If there is only the one you left, this session will have the number 0. You can attach to this session with

$ tmux attach -t 0

and we see, that our little “program” worked all the time.

Use this e.g. for database updates, backup jobs, or log file analysis.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s