Nohup command usage

Source: Internet
Author: User
When the nohup command is used to apply Unix/Linux, we generally want to run a program in the background, so we will usually use & amp; to automatically run the program at the end of the program. For example, we want to run mysql in the background:/usr/local/mysql/bin/mysqld_safe & amp; ndash; usermysql... when the nohup command is used to apply Unix/Linux, we generally want to run a program in the background, so we will usually use & to make the program run automatically at the end of the program. For example, we want to run mysql in the background:/usr/local/mysql/bin/mysqld_safe-user = mysql &. However, many programs do not want to use mysqld, so we need the nohup command. how can we use the nohup command? Here we will explain some usage of the nohup command. Nohup/root/start. sh & press enter in shell to prompt: [~] $ Appending output to nohup. out the standard output of the original program is automatically changed to the nohup. out file in the current directory, which plays the role of log. But sometimes there is a problem at this step. when the terminal is closed, the process will be automatically closed. check nohup. out to see that the service will be 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 with him when operating the terminal: when the shell prompts that nohup is successful, you also need to press any key on the terminal to return to the shell input command window, and then enter exit in the shell to exit the terminal; however, I click the close Program button to close the terminal every time the nohup operation is successful .. Therefore, the session corresponding to the command will be disconnected at this time, and the process corresponding to nohup will be notified and shutdown will be required together. I did not notice the details, so I recorded them here. 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 value: 126 can be searched 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 its 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 general form of this command is: nohup command & use nohup command to submit a job. if you use the nohup command to submit a job, by default, all the output of this job is redirected to a job named nohup. unless the output file: nohup command> myout is specified. file 2> & 1 & in the preceding example, the output is redirected to myout. file.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.