The nohup and & Linux usage and differences

The nohup and & Linux usage and differences

nohupAnd &the difference between

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

What does that mean? This means that, when you execute Command &time, even if you use ctrl C, you can still run a.out (SIGINT signal because immunity). But be careful, if you just turn off the shell, then, this same process Command disappear. Visible, & background is not hard (because SIGHUP signal is not immune).

nohup: that is, no hang up, do not hang up the running

nohup it means ignoring SIGHUP signal, so when the running nohup Commandtime, turn off the shell, then a.out process still exists (for SIGHUP signal immunity). However, be aware that if you directly in the shell using Ctrl C, then this process Command also will disappear (because of the SIGINT signal is not immune)

Note that the function does not run in the background, is that, with the 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 not running in the background meaning; & is running in the background

nohup syntax:

nohup Command [ Arg ... ] [ & ]

nohup runs a command specified by the Command parameter and any related Arg parameters of command, ignore all hang (SIGHUP) signals. The program runs in the background using nohup command after logout. To run a background in nohup command, add & (representation "and" sign) to the end of the command.
If you do not redirect the output nohup command, the output will be appended to the current directory nohup.outfiles. If nohup.out not write files in the current directory, output is redirected to $ HOME / nohup.out file. If the file can not be created or opened for append, then the Command parameter specifies the command is not invoked. If the standard error is a terminal, then the output of all the written standard error of the specified command is redirected to the same standard output file descriptor.

Guess you like

Origin www.cnblogs.com/mingyue5826/p/11572228.html