Prolonging terminal sessions: Difference between revisions

Jump to navigation Jump to search
swap order of tmux and screen, based on staff popularity
(→‎Terminal multiplexers: shorten callout text)
(swap order of tmux and screen, based on staff popularity)
Line 14: Line 14:
=Terminal multiplexers=
=Terminal multiplexers=


The programs <tt>screen</tt> and <tt>tmux</tt> are examples of a terminal multiplexer - a program which allows you to detach your terminal session entirely, where it will keep on running on its own until you choose to reattach to it. With such a program, you can logout from the cluster, turn off the workstation or hibernate the laptop you use to connect to the cluster and when you're ready to start working again the next day, reattach to your session and start from right where you left off.  
The programs <tt>tmux</tt> and <tt>screen</tt> are examples of a terminal multiplexer - a program which allows you to detach your terminal session entirely, where it will keep on running on its own until you choose to reattach to it. With such a program, you can logout from the cluster, turn off the workstation or hibernate the laptop you use to connect to the cluster and when you're ready to start working again the next day, reattach to your session and start from right where you left off.  
{{box|'''Login Node Dependency'''
{{box|'''Login Node Dependency'''
<br>
<br>
Each of our clusters has several login nodes and your <tt>tmux</tt> or <tt>screen</tt> session is specific to a login node. If you wish to reattach to a session, you must ensure you're connected to the right login node which of course means remembering which login node you were using when you started <tt>tmux</tt> or <tt>screen</tt>. Login nodes may also occasionally be rebooted, which will kill any detached terminal sessions on that node.}}   
Each of our clusters has several login nodes and your <tt>tmux</tt> or <tt>screen</tt> session is specific to a login node. If you wish to reattach to a session, you must ensure you're connected to the right login node which of course means remembering which login node you were using when you started <tt>tmux</tt> or <tt>screen</tt>. Login nodes may also occasionally be rebooted, which will kill any detached terminal sessions on that node.}}   


==GNU Screen==
==tmux==
The [https://en.wikipedia.org/wiki/GNU_Screen screen] program is a widely used terminal multiplexer. To create a detached terminal session, you can use the following command
{{Command|screen -S <session name>}}
It's a good idea to give a descriptive name to your terminal sessions, making it easier to identify them later. You can use the command <tt>screen -list</tt> to see a list of your detached terminal sessions on this node,
{{Command
|screen -list
|result=
There is a screen on:
        164133.foo      (Attached)
1 Socket in /tmp/S-stubbsda.
}}
You can attach to one of your sessions using the command <tt>screen -d -r <session name></tt>.


==TMUX==
The [https://en.wikipedia.org/wiki/Tmux tmux] software is a terminal multiplexer, allowing multiple virtual sessions in a single terminal session. You can thus disconnect from an SSH session without interrupting its process(es).
The [https://en.wikipedia.org/wiki/Tmux tmux] software is another terminal multiplexer, allowing multiple virtual sessions in a single terminal session. You can thus disconnect from an SSH session without interrupting its process(es).


===Cheat sheet===
===Cheat sheet===
Line 63: Line 51:


However, nested use of tmux is not recommended. To send commands to a nested tmux, one has to hit <tt>Ctrl+B</tt> twice; for example, to create a new window, one has to use <tt>Ctrl+B Ctrl+B C</tt>. Consider using [[#GNU Screen | screen]] inside your job (if you are using tmux on a login node).
However, nested use of tmux is not recommended. To send commands to a nested tmux, one has to hit <tt>Ctrl+B</tt> twice; for example, to create a new window, one has to use <tt>Ctrl+B Ctrl+B C</tt>. Consider using [[#GNU Screen | screen]] inside your job (if you are using tmux on a login node).
==GNU Screen==
The [https://en.wikipedia.org/wiki/GNU_Screen screen] program is a widely used terminal multiplexer. To create a detached terminal session, you can use the following command
{{Command|screen -S <session name>}}
It's a good idea to give a descriptive name to your terminal sessions, making it easier to identify them later. You can use the command <tt>screen -list</tt> to see a list of your detached terminal sessions on this node,
{{Command
|screen -list
|result=
There is a screen on:
        164133.foo      (Attached)
1 Socket in /tmp/S-stubbsda.
}}
You can attach to one of your sessions using the command <tt>screen -d -r <session name></tt>.
Bureaucrats, cc_docs_admin, cc_staff
2,879

edits

Navigation menu