I have an Ubuntu 14.04 virtual private server.
There are a few cronjobs defined:
00 03 * * * cd /root && ./backupJob.sh
00 04 * * * sudo -u www-data php /var/www/dir/htdocs/bin/indexer.php
00 05 * * * cd /root && ./cleanUpUploadedFilesJob.sh
Now the sysadmin receives an email for every cronjob that's executed, even on success. Note that I have a postfix running on the same machine and there is no MAILTO=""
in the crontab.
The goal is to only receive an email when the script has an exit value other than 0.
If I add 1>/dev/null
to every line, will my standard out be redirected? Will the behavior for standard error stay the same otherwise?
If i add 1>/dev/null to every line, will my standard out be redirected?
Yes, to /dev/null
. In effect, the STDOUT will be discarded and hence no mail will be sent for STDOUT.
Will the behavior for standard error stay the same otherwise?
Yes; just to note, if you need to redirect STDERR, you need to use file descriptor 2, for example, redirecting to /dev/null
(i.e. discarding the STDERR): ... 2>/dev/null
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments