tmux: Keep Linux Sessions Alive (so you can go back to the same terminal window from anywhere, anytime)
Quick cheat sheet for reference:Â
Concepts:Â Â Session, window, pane. You can also multiple tmux sessions, each of them can have multiple window, and each window can have multiple panes.
tmux new -s work   # create a new session
Ctrl+b, then c    # add a window to 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.
Thanks to the Linux developers for the tmux command, which can easily help us keep as many sessions as we want alive.
Jump start: If you don't want to understand the details, here is my simple and easy way to use tmux.
First, login to O2 using Linux/Mac terminal or Putty on Windows. Next you can start a tmux session:Â
Please notice, we started the tmux session on login01 here. Your node (computer) may be login02 or any other login nodes. You need remember it so you can come back later.
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 need turn off your computer or log out of O2, You can type Ctrl+b, then d for detach the session.
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:
Or if you just want to go the most recent active session:
If you want additional pane in a window, please type Ctrl + b, then %, then you got:Â
Now type Ctrl + b, then o switch to the first pane, run this command:Â
Now type Ctrl + b, then o switch to the second pane, run this command:Â
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
Please refer to the tmux README on Github:Â https://github.com/tmux/tmux/blob/master/README