The role of Linux nohup nohup method does not generate nohup.out

nohup command: If you are running a process, and you feel when you exit or close the account of the client process will not end, you can use the nohup command. The command to exit your account / continue to run the process after closing the corresponding terminal. All default output the job is redirected to a file named in nohup.out.

nohup command > myout.file 2>&1 &  

 

In the above example, 0 - stdin (Standard INPUT),. 1 - stdout (Standard Output), 2 - stderr (Standard error);

 

2> & 1 is the standard error (2) is redirected to the standard output (& 1), the standard output (& 1) and then is inputted to the redirected myout.file file.

 

1, nohup and & differences

&: Refers to run in the background

nohup: nohup command to run the permanent command execution continues, and the user terminal does not matter, for example, we disconnect the SSH connection will not affect his run, pay attention to the nohup does not mean running in the background; & is running in the background,

& Means run in the background, but when the user exits (hang) when the command automatically also pulled out

nohup can use Ctrl + C to end off, and use Ctrl + C & ends can not afford, not nohup terminal is closed, the user exits the impact, while & then closed by the terminal, the user exits the influence

Combined with that
nohup COMMAND &
this can make the order permanent in the background

2, the nohup method does not generate nohup.out

nohup java -jar /xxx/xxx/xxx.jar >/dev/null 2>&1 &

After the last key is> / dev / null 2> & 1 part, / dev / null space is a virtual device (similar to a black hole physics), any output is redirected to the device, it will go down the drain

> / Dev / null represents the standard output redirection information to the "black hole"

2> & 1 shows a standard error redirected to the standard output (output has been directed to the standard because "black hole", and namely: standard output at this time is a "black hole", then directed to the standard output standard error output, the error output is equivalent to is directed to a "black hole")

Guess you like

Origin www.cnblogs.com/zouhong/p/12191196.html