Use the nohup command to let the linux program run in the background

  
 

Use nohup to let the program run in the background forever. Under Unix/Linux, for example, you want a program to run in the background. Many of them use & at the end of the program to let the program run automatically. For example, we want to run mysql in the background: /usr/local/mysql/bin/mysqld_safe --user=mysql & but adding many of our programs does not make a daemon like mysqld, maybe our program is just a normal program, generally This program ends with & but if the terminal is closed, the program will be closed. But in order to be able to run in the background, then we can use the nohup command, for example, we have a test.php that needs to run in the background, and we want to run regularly in the background, then use nohup:nohup /root/test.php & : [~]$ appending output to nohup.out Well, it proves that the operation is successful, and the output information of the program is put into the nohup.out file of the current directory. Attached: nohup command reference nohup command Purpose: Run the command without hanging up. Syntax: nohup Command [ Arg ... ] [ & ] Description: The nohup command runs the command specified by the Command parameter and any associated Arg parameters, ignoring all hang up (SIGHUP) signals. Run the program in the background with the nohup command after logging out. To run the nohup command in the background, add & (symbols for “and”) to the end of the command. Whether or not the output of the nohup command is redirected to the terminal, the output is appended to the nohup.out file in the current directory. If the current directory's nohup.out file is not writable, the output is redirected to the $HOME/nohup.out file. If no files can be created or opened for appending, the command specified by the Command parameter is not callable. If the standard error is a terminal, then all outputs that write the specified command to the standard error are redirected as standard output to the same file descriptor. Exit Status: This command returns the following exit values: 126 You can find but not call the command specified by the Command parameter. 127 The nohup command has an error or cannot find the command specified by the Command parameter. Otherwise, the exit status of the nohup command is the exit status of the command specified by the Command parameter. Nohup command and its output file nohup command: If you are running a process and you feel that the process will not end when you log out of the 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. Nohup means no hhang up. The general form of the command is: nohup command & submit the job using the nohup command. If the job is submitted using the nohup command, by default all output of the job is redirected to a file named nohup.out unless Also specified is the output file: nohup command > myout.file 2>&1 & In the above example, the output is redirected to the myout.file file. Use jobs to view the task. Close with fg %n. In addition, there are two commonly used ftp tools ncftpget and ncftpput, which can implement ftp upload and download in the background, so I can use these commands to upload and download files in the background.

Copyright © Windows knowledge All Rights Reserved