Nohup method of non-output log information and Linux redirect learning

Source: Internet
Author: User
Tags linux

Cause

Recently used nohup created a background process, the default log output to the Nohup.out file, the program ran no longer tube, after about a week, found that the hard disk space is not enough, so find the reason, found that the Nohup.out file has been 70G, resulting in insufficient space on the hard disk.

Solution

Output only error messages to log files

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

I don't want any information.

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

Knowledge supplement, about Linux redirection

3 medium redirect for Linux

0: Indicates standard input

1: Standard output, in general use, the default is the standard output

2: standard error message output

Can be used to specify standard input or output that requires redirection. For example, the error message for a program is exported to the log file:./program 2>log. The standard output is still on the screen, but the error message is exported to the log file. In addition, redirects between 0,1,2 can also be implemented. 2>&1: redirect error information to standard output.

About/dev/null Files

Linux also has a special file/dev/null, it is like a bottomless pit, all redirected to its information will disappear without a trace. This is useful when we can redirect output to/dev/null when we do not need to echo all the information about the program.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

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.