Pay attention to the nohup command under Linux/solaris

The usage of the nohup command is as follows:
Generally, it is used as follows: nohup yourscript &

in order not to generate the file nohup.out, because this file is continuously appended, after a long time,
the file nohup.out will be particularly large, reaching more than 1G, In this case, the performance of the application will be affected.

Therefore, there are the following usages:
nohup yourscript > /dev/null &
this method will not generate the nohup.out file. If you want to see your log, you can view it in the log of your own application,
but this method will cause, use tail - When f yourlogfile, the log may not be flushed.

My point of view: The fact that the log is not refreshed is because the log files of the application are generated iteratively. For example, 5 files are set to be generated.
When the current log file is rolled over, the tail -f command will not detect and prompt, you can change it. Another parameter -F, that is, use:
tail -F yourlogfile, (tail: `yourlogfile' has been replaced; following end of new file). This command can detect that the file yourlogfile is overwritten and can automatically flush the output again. Therefore, the
recommendations are as follows: after using nohup, use tail -F instead of tail -f when viewing the log files of the application (premise: rolling generation).

Summary: During general development or integration testing, you can use the nohup yourscript & method to view the logs through
tail -f nohup.out. In the production environment, use the nohup yourscript > /dev/null & method.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326987813&siteId=291194637