Linux background running programs using the, such as Python main.py, the background run main.py, that is, CTRL + C after the program is still running in the background, PS aux|grep "python main.py" can be viewed. But when your Linux terminal shuts down, the program is not running, it accepts the signal of your terminal disconnect and shuts down the program. So how to make the system ignore the terminal disconnect signal, the terminal shutdown after the program is still running. It's easy to add a nohup to the command to ignore the terminal disconnect signal, and if you want to stop the program, you can use the KILL command only. The default output to the Nohup.out file when using Nohup is to use input-output redirection in Linux if you want to enter other files. Input-output redirection is supported in the Linux Shell environment, represented by the symbol "<" and ">". 0, 1, and 2 represent standard input, standard output, and standard error information output, which can be used to specify standard inputs or outputs that require redirection, such as 2>a.txt to output error messages to file A.txt.
In the meantime, redirects can be achieved between these three standard input outputs, such as redirecting error messages to standard output, and can be implemented using 2>&1.
Linux also has a special file/dev/null, it is like a bottomless pit, all redirected to its information will disappear without a trace. This is useful when we can redirect output to/dev/null when we do not need to echo all the information about the program.
If you want normal output and error messages to be displayed, redirect both standard output and standard error to/dev/null, for example:
# ls 1>/dev/null 2>/dev/null
Another approach is to redirect errors to standard output, and then redirect to/dev/null, for example:
# ls >/dev/null 2>&1
Note: The order here cannot be changed, otherwise the desired effect is not achieved, the standard output is redirected to/dev/null first, then the standard error is redirected to standard output, and the standard error is redirected to/dev/null because the standard output has been redirected to/dev/null. So it's all quiet:-)
In addition +:
Make >& Make_log
The meaning is to redirect both standard output and error output, make>out only the standard output is redirected!!!!!
>log means redirecting standard output to file log
>& log indicates that both standard output and error output are directed to the file log, equivalent to >log 2>&1 |