Use tmux for online operations to improve work efficiency and tmux to improve work efficiency
There is a headache for people who often perform online operations, that is, when something leaves, the computer automatically goes to sleep, and the network is disconnected, the task will be re-run at this time, very annoying.
Tmux can solve this problem. Tmux can be seen as a virtual screen without the impact of network disconnection. If the network is disconnected, connect the screen again, and the text on the virtual screen is still there.
Common commands for tmux are as follows:
Tmux new-s session_nametux attach-t session_nametmux lsControl + B d: disconnect temporarily. The ongoing task will not exit Control + B PageUp/PageDown
How can we use tmux to improve work efficiency? That is, the tmux is automatically enabled when the stepping stone is working. This is how I work.
First, define alias on the local computer and use the connection stepping stone as a command: alias gate = 'ssh xxx @ xxx ~ /Opentmux. Sh'
Stepping Stone host ~ /Opentmux. sh:
#! /Bin/bash # Find the unconnected screen session_name = 'tmux ls | grep-v attached | head-n 1 | egrep-O' ^ [^:] + ''# if no unconnected screen is found, create a new screen if [-z" $ session_name "]; then tmux exit # connect to the existing screen else tmux attach-t "$ session_name" exitfi
In this way, the screen in the detach status is automatically searched every time you connect to the stepping stone, and then automatically attach the screen. If all are in the attach status, a new window is created.
In this way, even if the network is disconnected, the task is still running when you connect to the stepping stone next time. Frequent online operations are not affected by network disconnection, which greatly enhances the operation experience.