i follow tutorial added this statement into my crontab,
*/10 * * * * /usr/mailscanner/bin/check_mailscanner > /dev/null 2<&1
but what meaning of "/dev/null 2<&1"
RutRow
07-03-2004, 12:23 PM
Hmm... mine is set up as "2>&1" not "2<&1". The first will redirect STDOUT and STDERR to /dev/null. I'm not exactly sure what the second will do.
kronologick
07-03-2004, 12:35 PM
indeed.
its just saying that whenever the cronjob is executed the results are redirected like RutRow says.
/dev/null is the 'trash bin' cept there is no recovering anything that is directed there.
hiryuu
07-03-2004, 04:02 PM
It should be '> /dev/null 2>&1' (STDERR is output-only)
As RutRow said, '> /dev/null' directs normal output into oblivion. The second takes STDERR (descriptor 2) and reroutes it as STDOUT (descriptor 1). Cron does this so that error messages may be recovered and sent in an e-mail, if any problems occur.
Note that order matters here. '2>&1 > /dev/null' would result in mixing STDERR into STDOUT, then sending BOTH into oblivion.
sigma
07-03-2004, 06:17 PM
Originally posted by hiryuu
Note that order matters here. '2>&1 > /dev/null' would result in mixing STDERR into STDOUT, then sending BOTH into oblivion.
Actually, in this case order doesn't matter. The ">/dev/null" part points STDOUT to /dev/null, and "2>&1" points STDERR to STDOUT. If you do ">/dev/null 2>&1" you send both to /dev/null. If you do "2>&1 >/dev/null", STDERR gets pointed to the old STDOUT before STDOUT is replaced with /dev/null, so your error messages do go somewhere.
Kevin