Using Linux redirection to resolve nohup.out no write permission issues

Source: Internet
Author: User

Scene

When executing the nohup command, there are often the following errors that do not have write permissions.

nohup:ignoring input and appending output to ' nohup.out '
nohup:failed to Run command '/etc/nginx_check.sh ': Permission denied

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.

when used in general, The default is 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.

Linux 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, when the standard output is redirected to/dev/null, and then the standard error is redirected to standard output.

Because standard output has been redirected to/dev/null, standard errors are redirected to/dev/null, so everything is quiet.

About Nohup

When using the Nohup command, it is often not possible to use nohup because the path of the output nohup.out does not have write permission.

This is a way to use Linux redirection, redirect nohup.out to a path with write permission, or throw it directly into/dev/null.

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

Or

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

Using Linux redirection to resolve nohup.out no write permission issues

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.