I have a few cron jobs and one of them is run every minute. I had to take a website down for two hours and it caused an error on that one specific cron job and I got almost 120 emails in those two hours until I was done upgrading the site.

Now let's say I was asleep and something happened. I don't want hundreds to thousands of emails because one cron job ran every minute and failed. Is there something I can do to limit how often it emails me while allowing it to run every minute?

PS: We don't have smtp servers, we use a 3rd party so I am glad nothing was marked as spam and disabled.


You should employ some mechanisms to make sure the cronjobs/monitoring services are aware of the downtime/scheduled maintenance. Many programs lately such as Nagios, Zabbix offer such solution where in you can perform the scheduled maintenance and make Nagios aware of it through its interface , during which time, Nagios will not attempt to monitor the service.

Or more simpler, not to bloat onto use heavy Nagios for a single simple service monitoring service, make the cronjob script aware of some file locking mechanism, if the file lock exists, ignore any state for the service and do not spurr or yell on the output. It is upto Administrator to make sure that the file lock is removed after the scheduled maintenance is over, so that cronjob script can take back to start monitoring the system.

  • Sounds a bit complicated but do able. The cronjob in question is actually wordpress's cron.php file. I'll need to look at how i can execute it and capture the stdout and then using a file lock idea to 'silence' it until success. +1 and i'll accept if no other answers. – user4069 Jan 4 '12 at 9:00

By default cron will email you any output any of the cron jobs generate, either to stdout or stderr.

Personally I redirect all output to a log file with a datestamp of the run as part of the filename.

If you want ot be notified, do the same and then use another cron job to mail you every N hours

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy