[Turn]-nohup-real shell background run

Source: Internet
Author: User
Tags exit in

& Method:
Unix/linux generally want to let a program run in the background, many 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 &

Nohup Way:
However, many of our programs are not as mysqld as the Guardian process, perhaps our program is only ordinary programs, generally this program even use & end, if the terminal is closed, then the program will be closed.
In order to be able to run in the background, we need to use the Nohup command, such as we have a start.sh need to run in the background, and want to be able to run in the background, then use Nohup:

Nohup/root/start.sh & in the shell after enter the prompt: [~]$ appending output to nohup.out the original program's standard output is automatically redirected to the current directory of Nohup.out files, played the role of log.

Nohup questions:
But sometimes in this step there is a problem, when the terminal is closed, the process will be automatically closed, see Nohup.out can be seen in the shutdown Terminal Instant service automatically shut down.
The details of the terminal: when the shell prompts the nohup to be successful, you also need to press any key on the terminal to return to the Shell Input Command window, and then exit the terminal by entering exit in the shell;

And I am every time after the successful execution of the Nohup, the Close Program button closes the terminal.

So this time will be broken the corresponding session of the command, resulting in nohup corresponding process is notified need to shutdown together. This detail has not been noticed by me, so I recorded it here.

Attached: nohup Command Reference
Nohup command
Purpose: To run the command without hanging off.
Syntax: Nohup Command [Arg ...] [&]
Description: The nohup command runs commands specified by the command parameter and any related ARG parameters, ignoring all hang-up (SIGHUP) signals.
Use the Nohup command to run a program in the background after logging off. To run the Nohup command in the background, add & (the symbol representing "and") to the end of the command.

The output is appended to the Nohup.out file in the current directory, regardless of whether the output of the Nohup command is redirected to the terminal. If the nohup.out file for the current directory is not writable, the output is redirected to the $HOME/nohup.out file.
If no file can be created or opened for appending, then the command specified by the commands parameter is not callable.

If the standard error is a terminal, then all output of the specified command to the standard error is redirected to the same file descriptor as the standard output.

[Turn]-nohup-real shell background run

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.