Most of the time, I use the SSH command line to connect to my remote server. Unfortunately, my SSH session is lost because the power is down today and the network hub is closed. What if your SSH session for an important job is lost? Here is a simple tool called Tmux that keeps a process record after the Putty or SSH session ends. Tmux is a terminal multiplexing. It supports the creation, access, and control of multiple terminals in a single window. Tmux continues after you disconnect
Most of the time, I use the SSH command line to connect to my remote server. Unfortunately, my SSH session is lost because the power is down today and the network hub is closed. What if your SSH session for an important job is lost? Here is a simple tool called Tmux that keeps a process record after the Putty or SSH session ends.
Tmux is a terminal multiplexing. It supports the creation, access, and control of multiple terminals in a single window. Tmux continues running after you disconnect the connection. after you reconnect, you can get the previous working status.
The procedure is as follows:
First, install Tmux on your remote computer.
RPM-based systems:
Yum install tmux
DEB-based systems:
Apt-get install tmux
After installing Tmux, SSH is connected to your remote computer. here, CentOS 7 is used as an example.
Ssh root @ IP address
Open your terminal and run Tmux.
Tmux
Then run the task you want to execute.
Here, we use upgrading CentOS 7 as an example.
Yum update
Running result:
The update process is currently running. Press D and press Ctrl + B to exit the tmux session.
Now, return to the actual terminal, but the working process is still running in the tmux session. Use SSH to disconnect and connect to the remote computer again. Enter tmux attach in the terminal
Tmux attach
Display the status of your job
Similarly, you can run the tasks you need in a tmux session. the number of tasks is unlimited. Of course, you can use Ctrl-B and $ to rename each session.
You can view the number of running tmux sessions:
Tmux list-sessions
Example:
0: 1 windows (created Thu Jan 8 15:13:42 2015) [80 × 23]
1: 1 windows (created Thu Jan 8 15:20:05 2015) [80 × 23]
The functions of Tmux are far more than described above. we can run tasks that require long execution on a remote computer and then disconnect them, you can log on again later and view the running status through Tmux.