When using Linux, it is often desirable that some command results not be displayed in the foreground, such as SH scripts, time-consuming commands, etc.
In general, use & to run the command results in the background, such as SH test.sh, script background execution.
Sometimes the command has been executed in the foreground, you need to switch it to the background can be used, CTRL + Z, but the command to switch to the background will be in a paused state, you can cooperate with jobs to further process the background commands (process).
The more extreme situation is that some commands take a long time but cannot be interrupted, such as downloading ... , the nohup (ignoring hangup signals) is required to ignore the pending signal being executed in the background.
Comparison of & with Nohup:
&: Run in the background, but when the user terminal exits (disconnected), the command ends
Nohup test.sh &: Running in the background, when the user terminal exits (the disconnection) remains in operation, the standard input and output can be used.
If you submit a job using the Nohup command, all output from the job is redirected to a file named Nohup.out by default, unless the output file is specified separately:
such as: Nohup command > Myout.file 2>&1 &
Specified output to file Myout.file
2>&1 is redirecting standard errors to standard output, where the standard output has been redirected to the Out.file file, and the standard error is output to the Out.file file. The last & is to have the command execute in the background.
Use examples to refer to:
Https://www.cnblogs.com/MYSQLZOUQI/p/5283761.html
Linux background run Nohup & Ctrl + Z