Im using a crontab like:
00 */1 * * * wget http://www.test.com/cron/archieve
I would like to know the difference using > /dev/null 2>&1 in the end of the command, and if its recomended.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you do not add
> /dev/null 2>&1, output of that command will be mailed to user that this cron job runs at – probably you.I would imagine you don’t want to be spammed by cron jobs – but this is up to you
EDIT: explanation what
> /dev/null 2>&1really means.There are 3 standard file descriptors: 0 (stdin), 1 (stdout) and 2 (stderr).
> fileis the same as1> file, in other words, redirect std. file descriptor 1 (stdout) to file.2>&1means redirect std. file descriptor 2 (stderr) to the same place where 1 (stdout) is redirected.In the end, full effect of
> /dev/null 2>&1means redirect both stdout and stderr to/dev/null, in other words make that program completely silent