Use tmux for online operations to improve work efficiency and tmux to improve work efficiency

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.