Tmux¶
Tmux is a terminal multiplexer. It keeps your terminal session running on the login node even when you disconnect, so long-running commands such as data transfers, compilation or environment installation are not interrupted when your network connection drops or you close your laptop.
Warning
Tmux runs on the login node. Use it for transfers, editing and job management, not for computations. Computations always belong into a job.
Basic Usage¶
tmux new -s work # Start a new session named "work"
tmux ls # List your sessions
tmux attach -t work # Reattach to the session "work"
tmux kill-session -t work # Close the session "work"
Inside tmux, commands are entered with the prefix Ctrl+B followed by another key.
| Keys | Action |
|---|---|
| Ctrl+B D | Detach from the session, it keeps running. |
| Ctrl+B C | Create a new window. |
| Ctrl+B N / P | Switch to the next / previous window. |
| Ctrl+B % | Split the window vertically. |
| Ctrl+B " | Split the window horizontally. |
| Ctrl+B Left | Move between split panes. |
| Ctrl+B [ | Scroll mode, exit with Q. |
Example¶
Start a long transfer in tmux, disconnect and check it later.
ssh your_user_name@login.hpc.imtm.cz
tmux new -s transfer
rsync -avP /project/my_project/data/ /project/other_project/data/
Press Ctrl+B D to detach and log out. The transfer keeps running. Later, log in again and reattach:
Tip
An interactive job started inside tmux survives a dropped connection too. Start tmux on the login node first and then run qsub -I ... inside it.