Multiplexing terminals so that programs run in the background - Green-Biome-Institute/AWS GitHub Wiki
Before running any program that will take a long time to run, it is a good idea to create a separate terminal session where that program will run. This can be thought of as a second desktop of your computer, which runs programs in the background uninterrupted, while you do other things. For this purpose we will use the program "tmux." This software gives the ability to mulitplex terminal sessions, meaning you can create new ones, and then "attach" and "detach" from them, which can be though of as logging into and out of them, while they continue to run. So before you launch an assembly, you will want to create a new terminal session using tmux, attach into it, start the assembly within that new session, then detach from it. This gives you the ability to re-attach anytime you want to check the status of the assembly or to exit the entire instance without stopping your program from running.
Tmux is pre-installed on Ubuntu instances. As always, look into the documentation provided at the bottom when you have any questions. Some simple commands to get you started are as follows:
Using Tmux
To create a new session:
tmux new -s [session-name]
ex. tmux new -s arabidopsis-assembly
will launch you into a new terminal called "arabidopsis-assembly". You can still use all the same commands to navigate around the computer, but everything you do will be separate from the main terminal.
To detach from a terminal session:
Press the 'control' button and then the letter 'B' button at the same time, and then release them. This tells tmux that you are about to give it a command to do something. After releasing those buttons, press the letter 'D' button. You will be detached from the "arabidopsis-assembly" terminal and re-attached to the main terminal. Any programs you started on the "arabidopsis-assembly" terminal will continue to run!
To attach back into a terminal session:
tmux a -t [session-name]
ex. tmux a -t arabidopsis-assembly
Will launch the "arabidopsis-assembly" terminal, where you can monitor the progress of your assembly or other program! Super rad!
If you forget what your tmux session is named and want to list all of the existing tmux sessions:
tmux ls
Or delete a given session:
tmux kill-session –t [session-name]
ex. tmux kill-session -t arabidopsis-assembly
Further information
https://tmuxguide.readthedocs.io/en/latest/tmux/tmux.html