screen makes time-consuming programs running when ssh remotely access the server uninterrupted

Found a weapon: screen!

Screen can make some time-consuming programs or operations in execution not interrupted when disconnecting the ssh remote server connection, how great! In this way, the remote server can run the program for a long time, even if it takes a long time, it does not matter

Specifically, install screen first:
sudo apt-get install screen
(the specific installation command varies with different operating systems, please Baidu yourself)

After installation, execute:
screen -S t1
(screen - S virtual terminal name, this name can be chosen arbitrarily)

After that, you will be in the virtual terminal, and then you can execute commands or operations or execute time-consuming programs.
If you want to switch back to the normal terminal, you can press and hold Ctrl and then press A, D in sequence, release A and then press D.

To see the current virtual terminal:
screen -ls

Switch back to a virtual terminal:
screen -r t1
(screen -r virtual terminal name)

Delete a virtual terminal:
screen -ls
(view the session name of the virtual terminal)
screen -S xxxx.t1 -X quit
(screen -S virtual terminal name -X quit)

After disconnecting and re-entering, you will find that the virtual terminal is still there, and the operations or programs in the virtual terminal are still running, great!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325644988&siteId=291194637