Skip to content

TMUX guide

Loic Royer edited this page Apr 13, 2021 · 1 revision

use tmux to keep track of long runing jobs

Why tmux? When you connect via network adn SSH, you can start a process on a remote machine, but it often occurs that closing the terminal or loosing the network connection will kill the running process. Even if one figures out how to keep the processs running, you rarely can see again the log outputs - unless you have explictely redirected to a file. tmux greatly simplifies all this by providing persistent terminal sessions.

First make sure that tmux is instaled on your system:

sudo apt-get install tmux

Connect to your machine using, for example, ssh:

ssh username@machine

Create the session in which you want to run your long-running process:

tmux new -s dexp

Once in your session you can activate the dexp environment, and start dexp, etc...

Important: You can leave a session by pressing the keys: CTRL+B then D

To come back to a session, you reattach:

tmux attach -t dexp

Once a session is created, it will remain active until you close it, no need to create it again (unless you have closed it!). You can disconnect your SSH session, loose network connection, close your computer, and still be able to reconnect to your session and have everything as if you had kept everything open.

In doubt, you can list all active sessions:

tmux ls

To close a session: First kill, if needed, the running process within the session by pressing CTRL+C or/and CTRL+Z, and then, simply type the command exit in the termnal within the session.

Note: you might encounter problems in tmux with text coloring. A solution is to change the default xterm setting:

First, generate a default configuration file for tmux:

tmux show -g | cat > ~/.tmux.conf

Add the following line at the end of that file (~/.tmux.conf):

set -g default-terminal "screen-256color"

Clone this wiki locally