The linux command nohup disconnected the ssh connection, and the server was still running the program. I was confused for a long time. -Guide from Liu Shuai

nohup The
nohup command runs the command specified by the Command parameter and any related Arg parameters, ignoring all hang-up (SIGHUP) signals. After logging out, use the nohup command to run the program in the background. To run the nohup command in the background, add & (the symbol for "and") to the end of the command.

Nohup is the abbreviation of no hang up, which means not to hang up, but there is no background operation, and the terminal cannot be standard input.

The nohup command: If you are running a process, and you feel that the process will not end when you log out of your account, you can use the nohup command. This command can continue to run the corresponding process after you log out of the account/close the terminal.

By default, all output of the job is redirected to a file named nohup.out. Or> /dev/null is discarded into the black hole

Case study

  1. nohup command > myout.file 2>&1 &

In the above example, 0 – stdin (standard input), 1 – stdout (standard output), 2 – stderr (standard error);

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

  1. 0 22 * * * /usr/bin/python /home/pu/download_pdf/download_dfcf_pdf_to_oss.py > /home/pu/download_pdf/download_dfcf_pdf_to_oss.log 2>&1

This is a timed task in crontab. I am afraid at 22 o'clock in the evening.

Guess you like

Origin blog.csdn.net/gz153016/article/details/108021184