| UNIX/In Linux, you generally want to run a program in the background. Many of them use & at the end of the program to run the program automatically. For example, to run MySql in the background: /Usr/local/MySQL/bin/mysqld_safe -- user = MySQL & However, many of our programs do not support daemon like mysqld. Maybe our program is just a common program. Generally, even if this program is used and ended, if the terminal is closed, the program will also be closed. To be able to run in the background, we need to useNohupFor example, if we have a start. Sh command that needs to be run in the background and want to be able to run it all the time in the background, useNohup: Nohup/Root/start. Sh & After you press enter in shell, the following message is displayed: [~] $ Appending outputNohup. Out The standard output of the original program is automatically redirected toNohupThe. Out file plays the role of log. However, sometimes there is a problem at this step. When the terminal is closed, the process will be automatically closed.Nohup. Out you can see that the service is automatically closed when the terminal is closed. After consulting with the red-flag Linux engineer, he could not solve the problem. After executing the command on my terminal, the process he started was still running after the terminal was closed. During the second demonstration to me, I found that I had a different detail from the one I used to operate the terminal: he prompted me in the shell.NohupAfter success, you need to press any key on the terminal keyboard to return to the shell input command window, and then enter exit in shell to exit the terminal.NohupClick CLOSE program to close the terminal .. Therefore, the session corresponding to this command will be broken at this time, resulting inNohupThe corresponding process to be notified must be shut down together. I did not notice the details, so I recorded them here. Appendix:NohupCommand reference NohupCommandPurpose: run the command without hanging up. Syntax:NohupCommand [arg...] [&] Description:NohupRun the command specified by the command parameter and any relevant Arg parameter to ignore all sighup signals. UseNohupCommand to run the program in the background. To runNohupCommand to add the & (symbol indicating "and") to the end of the command. Whether or notNohupCommand output is redirected to the terminal, and the output will be appended to the current directoryNohup. Out file. IfNohupThe. Out file cannot be written, and the output is redirected to $ 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. 127NohupA command error occurs or you cannot find the command specified by the command parameter. Otherwise,NohupThe command exit status is the exit status of the command specified by the command parameter. NohupCommand and its output file NohupCommand: If you are running a process and you think the process will not end when you exit the account, you can useNohupCommand. This command can continue running the corresponding process after you exit the account/Close the terminal.NohupMeaning not to suspend (N ohang up ). The command is generally in the following format:NohupCommand & UseNohupCommand to submit a job If you useNohupCommand to submit a job. By default, all output of the job is redirected toNohupIn the. Out file, unless the output file is specified separately: NohupCommand> 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. There are also two commonly used FTP tools ncftpget and ncftpput, which can be used to upload and download files in the background through FTP, so that you can use these commands to upload and download files in the background. |