most crontab scheduled Tasks, at the end of the command line will take >/dev/null 2>&1, what is the role of it?
> delegate redirection;
/dev/null represents an empty device file, equivalent to a recycle Bin. null is a thing called a null keg that redirects the output to its good
is: The file size is not increased because of too much output, which means that the output of the command is discarded.
1 represents the stdout standard output, the system default value is 1, so ">/dev/null" is equivalent to "1>/dev/null"
2 indicates stderr standard error output;
& 2>&1 means that the standard error output is redirected to the standard output stdout.
# The meaning of the sentence is that the standard output redirects to the empty device file, which means no output of any information to the terminal, standard error output redirection, etc.
Same as standard output, the standard error output is also redirected to an empty device file because the standard output was previously redirected to an empty device
Thing
1,command >file 2>file meaning
# indicates the standard output information generated by the command, and the incorrect output information is sent to file . But file will be opened two times, and
StdOut and stderr will cover each other, which is equivalent to using FD1 and FD2 two simultaneously to seize the file of the pipeline.
2,command >file 2>&1 meaning
# indicates that the stdout is sent directly to file, stderr inherits the FD1 pipeline, and then is sent to file, at this time,file Only be opened once, also only
used a pipe FD1, which includes all the contents of stdout and stderr .
from IO efficiency, the efficiency of the previous command is less efficient than the latter, so when writing a shell script, we often use
Command > file 2>&1 such a notation.
This article is from "Tornado" blog, please make sure to keep this source http://ruilong.blog.51cto.com/4043170/1763289
Crontab Common/dev/null 2>&1 detailed