Linux boot background service nohup >/dev/null

Source: Internet
Author: User

Linux redirection 0, 1, and 2 represent standard input, standard output, and standard error message output, which can be used to specify the standard input or output that needs to be redirected.
In general use, the default is the standard output, both 1. When we need special use, we can use other labels. For example, output a program's error message to the log file:./program 2>log. The standard output is still on the screen, but the error message is output to the log file.
In addition, redirects can be implemented between 0,1,2. 2>&1: redirect error messages to standard output.   /dev/nullLinux also has a special file/dev/null, it is like a bottomless pit, all the information redirected to it will disappear into a trace. This is useful when we do not need to echo all of the program's information, so we can redirect the output to/dev/null.

If you want both the normal output and the error message to be displayed, redirect both the standard output and the standard error to/dev/null, for example:

# ls 1>/dev/null 2>/dev/null

Another approach is to redirect errors to standard output and then redirect to/dev/null, for example:

# ls >/dev/null 2>&1

Note: The order here cannot be changed, otherwise the desired effect is not achieved, the standard output is redirected to/dev/null, then the standard error is redirected to standard output, and the standard error is redirected to/dev/null because the standard output has been redirected to/dev/null , so everything was quiet:-)

Nohup combined with /dev/null

Because of the use of nohup, the output is automatically written to the Nohup.out file, if the file is large, nohup.out will continue to grow, which we do not want to see, so you can use/dev/null to solve the problem.

Nohup./program >/dev/null 2>log &

If the error message is not wanted:

Nohup./program >/dev/null 2>&1 &




Linux boot background service nohup >/dev/null

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.