Use nohup to keep the program running in the background forever
In Unix/Linux, for example, if you want a program to run in the background, many of them use & to make the program run automatically at the end of the program. For example, to run MySql in the background:
/Usr/local/MySQL/bin/mysqld_safe -- user = MySQL &
However, joining many of our programs is not a daemon like mysqld. Maybe our program is just a common program. Generally, this program is used and ended, but if the terminal is closed, the program will also be closed. However, in order to be able to run in the background, we can use the nohup command. For example, if we have a test. php that needs to run in the background and want to run it regularly in the background, we can use the nohup command:
Nohup/root/test. php &
Tip:
[~] $ Appending output to nohup. Out
Well, it proves that the program runs successfully. At the same time, it puts the output information of the program running in the nohup. Out file of the current directory.
Appendix: 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 relevant Arg parameter, ignoring all sighup signals. After logging out, run the nohup command to run the program in the background. To run the nohup command in the background, add the & (symbol indicating "and") to the end of the command.
Whether or not the output of the nohup command is redirected to the terminal, the output will be appended to the nohup. Out file in the current directory. If the nohup. Out file in the current directory cannot be written, the output will be redirected to the $ home/nohup. Out file. If no file can be created or opened for append, the command specified by the Command Parameter cannot be called. If a standard error is a terminal, write the specified command to all outputs of the standard error as the standard output and redirect it to the same file descriptor.
Exit status: This command returns the following export values:
126 you can find but cannot 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 output file
Nohup command: If you are running a process and you think the process will not end when you exit the account, you can use the nohup command. This command can continue running the corresponding process after you exit the account/Close the terminal. Nohup means not to suspend (N ohang up ).
The command is generally in the form: Nohup command &
Use the nohup command to submit a job
If you use the nohup command to submit a job, all the output of the job is redirected to a file named nohup. Out by default, unless the output file is specified separately:
Nohup command> myout. File 2> & 1 &
In the preceding example, the output is redirected to the myout. File file.
Use jobs to view tasks.
Disable using FG % N.
Two other ftp tools, ncftpget and ncftpput, can be used to upload and download files in the background through FTP, so that I can use these commands to upload and download files in the background.
Tags:Nobup
Address: http://www.21andy.com/blog/20071121/677.html