Quick cheat sheet for reference:
Code Block |
---|
Concepts: Session, window, pane. You can also multiple tmux sessions, each of them can have multiple window, and each window can have multiple panes. |
Code Block |
---|
tmux new -s work # create a new session |
Code Block |
---|
Ctrl+b, then c # add a window to a session |
Code Block |
---|
Ctrl+b, then 1 # switch to window 1 in the same session. You can change 1 to other numbers. |
Code Block |
---|
Ctrl+b, then % # add a pane to window |
Code Block |
---|
Ctrl+b, then o # switch panes in the same window |
Code Block |
---|
Ctrl+b then d # detach a session |
Code Block |
---|
tnum attach -t work # re-attach to session 'work' |
Code Block |
---|
tmux a # re-attach to the last session used |
Code Block |
---|
Ctrl+d # kill a pane, a window, a session |
Details:
Some bioinformatics software pipeline need long time to run and need us to monitor the progress from time to time. But we often can not keep our computer always on to keep the linux session on. Also the internet connection may get lost, then you will miss the session.
...
First, login to O2 using Linux/Mac terminal or Putty on Windows. Next you can start a tmux session:
Code Block | ||
---|---|---|
actionscript3 | actionscript3 | ld32@login01:~$ tmux new -s work |
...
Now you should have a window like:
...
So there are 1 windows (0:bash*) inside this session. The * means the window is active now.
To add one more window, you can type Ctrl+b (hold the ctrl or control key, then type "b"), then c. You get something like:
...
So there are two windows now, 0:bash- and 1:bash*. And 1:bash* is active window now.
...
When you want to go back to the previous session, first log on to O2 as before, check if you land on the original tmux session's starting node or not, if not ssh to the original node (computer), then re-attach:
Code Block | |
---|---|
actionscript3 | ld32@login02:~$ ssh login01 ld32@login01:~$ tnum attach -t work |
Or if you just want to go the most recent active session:
Code Block | ||
---|---|---|
actionscript3 | actionscript3 | ld32@login01:~$ tmux a |
If you want additional pane in a window, please type Ctrl type Ctrl + b, then %, then you got:
...
Now type Ctrl + b, then o switch to the first pane, run this command:
Code Block | actionscript3 | actionscript3
---|
ld32@login01:~$ srun --pty -p interactive -t 0-12:0:0 --mem 2G -n 1 /bin/bash # here is the output: srun: job 14996113 queued and waiting for resources srun: job 14996113 has been allocated resources ld32@compute-e-16-231:~$ # Now I am on computer-e-231, so that I can run my software ld32@computer-e-16-231:~$ ./my_fancy_analysis.sh |
Now type Ctrl + b, then o switch to the second pane, run this command:
Code Block | actionscript3 | actionscript3
---|
ld32@login01:~$ ssh computer-e-16-231 ld32@compute-e-16-231:~$ # Now I am on computer-e-231, so that I can check software (my_fancy_analysis.sh) running status from this pane ld32@computer-e-16-231:~$ htop -u $USER |
So you can monitor process running status from the seond pane while the software is running in the first pane:
...
For more information on tmux
...