CentOS: Disable cron notifications

detox1978 used Ask the Experts™
Hi All,

I have the following in my cronttab

* * * * * php /var/www/www.mydomain.com/cron.php

Every time it runs i am sent an email.  How do i switch this off?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Post the contents of that file:

cat /var/www/www.mydomain.com/cron.php


The PHP does several MySQL imports.  It doesn't send any emails.  

Is that all that is in crontab?

I'd look to syslog then.
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.


can i not just append/prefix the it with something like   "/dev/null >"
That depends on what's sending the mail...

You could use something like:

* * * * * php /var/www/www.mydomain.com/cron.php    1>/dev/null 2>/dev/null

* * * * * php /var/www/www.mydomain.com/cron.php    >/dev/null 2>&1
* * * * * php /var/www/www.mydomain.com/cron.php    &> /dev/null

You could also blank out the send-to address by putting this at the top of the crontab file:


All that should stop cron from sending it to you.  You might need to restart crond with:
/etc/init.d/crond restart

If you use the "crontab -e" command to edit crontab it should do the restart for you.


Since you've got an email it means that the script is creating an output. Since it can not display it interactively it is sending you an email. So the best thing to do is to direct its output to /dev/null but keep in mind that if anything goes wrong you won't know about it. This is why you should not redirect the standard error to anywhere so that you'll get a mail if something goes wrong.

The syntax will be:

* * * * * php /var/www/www.mydomain.com/cron.php  > /dev/null


By default cron jobs sends a email to the user account executing the cronjob. The cron job is executing "php /var/www/www.mydomain.com/cron.php" as if you are executing the job. If it is not necessary that the cron job has to run with your credentials, delete the cronjob from your account and create it for a different account.

good luck..

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial