Linux command after the run -nohup

  

Under Linux/Unix, usually only the daemon can continue to execute without the terminal, and the normal process will exit when receiving the SIGHUP signal (suspend signal) when the terminal is shut down. . When the terminal exits, the background program started by the terminal automatically exits.

If you want the command to run in the background, you can use the & specified command to run in the background;

If the program does not stop running after the terminal exits, the background program can be started with the nohup command.

nohup(=no hang up), so that the command ignores the SIGHUP signal; [syntax] nohup Command [ Arg ... ] [&] [command output description]

Not redirected, either standard output (stdout) or standard error (stderr), redirected to the nohup.out file; nohup.out file is written by default in the current directory, if there is no write permission in the directory , trying to write to $HOME/nohup.out, if it still fails, the entire command fails;

If the command output is redirected, it will be written to the specified redirect file;

[Exit Status] 126 can find but can't call Command command; 127 nohup command error or command command cannot be found; otherwise it is the exit status of Command command; nohup and & difference: nohup just let the command ignore the SIGHUP command;

& let the command run in the background;

As to whether the command can continue to execute after leaving the terminal, it depends on whether the process is a daemon, if not, then nohup is needed to help;


PS, reference http://www.cnblogs.com/allenblogs/archive/2011/05/19/2051136.html< Br>

---------The following is the reference content


When he prompts nohup in the shell, he still needs to press any key on the terminal to return it. Go to the shell and enter the command window, then exit the terminal by typing exit in the shell; and I will close the terminal by clicking the Close button directly after the nohup is successfully executed. Therefore, the session corresponding to the command will be disconnected at this time, and the process corresponding to nohup is notified that it needs to be shut down together.

This detail has not been noticed like me, so record it here.

Copyright © Windows knowledge All Rights Reserved