Run the Linux Command-nohup & amp;

Source: Internet
Author: User
Tags exit in

In Linux/Unix, only the daemon can continue to run without the terminal. When a common process closes the terminal, it exits because it receives the SIGHUP signal (suspension signal. After the terminal exits, the background program started by the terminal automatically exits.

If you want to run the command in the background, run the command in the background;

If you want to stop running the program after the terminal exits, use the nohup command to start the background program.

Nohup (= no hang up), so that the command ignores the SIGHUP signal;
[Syntax] nohup Command [Arg...] [&]
[Command output description]

If the Command output is not redirected, both stdout and stderr are redirected to nohup. out file; nohup. the out file is written in the current directory by default. If you do not have the write permission in this directory, try to write it to $ HOME/nohup. out. If it still fails, the entire command fails to be executed;

If the Command output is redirected, it is written to the specified redirected file;

[Exit status]
126 the Command can be searched but cannot be called;
127 nohup Command error or Command cannot be found;
Otherwise, the Command exits;

Differences between nohup and:
Nohup only allows the command to ignore the SIGHUP command;

& Enables the command to run in the background;

Whether the command can be executed after leaving the terminal depends on whether the process is a daemon. If not, nohup is needed to help;

 

PS, reference http://www.cnblogs.com/allenblogs/archive/2011/05/19/2051136.html

--------- Reference content below

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.


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.