Linux troubleshooting: How do I save the working status after the SSH session is closed?
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.
You can also run the following command to view more information:
Man tmux
Tmux 1.8 released, a Linux terminal multiplexing
Tmux: terminal multiplexing
Simple tmux tutorial
Install and use Tmux in CentOS
Tmux in CentOS creates a perfect terminal management tool
Tmux details: click here
Tmux: click here
This article permanently updates the link address: