Linux lets the program run the command in the background screen and nohup

一、nohup

Nohup will break for a long time, so it is recommended to use screen

nohup command & 

If the operation is successful, the standard output will be redirected to the nohup.out file in the current directory by default. Check this file to see that the progress 
 of the operation will be interrupted after a long time. 

That is, after ssh is opened, bash, etc. are all his subprograms. Once ssh is closed, the system will kill all related processes! ! Causes the task in execution to be canceled once ssh is closed

 

2. screen
1. Install screen
yum install screen

2. Create a screen session
screen -S Define a session name by yourself. It is best to remember to return to the session
and execute the command

3. Leave temporarily and keep the tasks or programs in the screen session
. When you need to leave temporarily (the program in the session will not be closed, it is still running), you can use the shortcut key Ctrl+ad (that is, press and hold Ctrl, and then press a, d in turn)

4. When the screen session is restored
, you can execute it again when you come back: screen -r session name to restore to the working interface of the lnmp session created before leaving.

If you forget or did not specify the session name at the beginning, execute screen -ls to list the current session list;

 

Execute screen, press any key to enter the sub-interface;
I use the ping command to start the execution, if I am off work, but I want to close ssh and continue to run ping, then press ctrl+a and then press d to pause the sub-interface, it will display [detached] Word, at this time I returned to the parent interface;
use screen –ls to view the current status of the child interface

screen -ls
There is a screen on: 22292.pts-3.free (Detached)
1 Socket in /tmp/screens/S-root。

The 22292 here is actually the pid number of the sub-interface;
if you go back to the sub-interface and use screen -r 22292, you will be sent to the sub-interface of ping;


Guess you like

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