lunes, 22 de agosto de 2016

not sending cron emails for Standard Error or Standard ouput

up vote54down voteaccepted
> is for redirect
/dev/null is a black hole where any data sent, will be discarded
2 is the file descriptor for Standard Error
> is for redirect
& is the symbol for file descriptor (without it, the following 1 would be considered a filename)
1 is the file descriptor for Standard Out
Therefore >/dev/null 2>&1 is redirect the output of your program to /dev/null. Include both the Standard Error and Standard Out.
Much more information is available at The Linux Documentation Project's I/O Redirection page.
cron will only email you if there is some output from you job. With everything redirected to null, there is no output and hence cron will not email you

x * * * * /path/to/my/script > /dev/null 2>&1

sending the output to a file and error  to other
find / -name "*.rpm" >> /home/rpm-results.txt 2> /home/rpm-errror.txt
http://unix.stackexchange.com/questions/163352/what-does-dev-null-21-mean-in-this-article-of-crontab-basics

No hay comentarios:

Publicar un comentario