Stop the php5 cron emails

Posted March 2, 2016 10.5k views
UbuntuSystem Tools

Hi, I have installed SSMTP - and everything works, but now I’m getting some Cron emails that I wasn’t expecting.

I’ve tried a number of things to try to disable them, but nothing seems to be working.

Delivered: → 'Cron <root@windfarm> [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime) > /dev/null 2>&1'

I’ve tried adding mailto="" before the cron command.
I’ve also tried appending > /dev/null 2>&1 as you can see above.

Anyone have some suggestions?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Chaining the commands this way should result in a single exit which would have it’s output redirected to /dev/null preventing the email but without seeing the exact line in the crontab it’s hard to tell for sure.

The mailto option to stop all cron related emails can be done like this.

Open /etc/crontab in an editor

You should see these lines:


Directly after those, append:


Then save the file and run

service cron restart

and the change should take effect.

  • Hi @ryanpq - sorry for the late response … unfortunately your suggestions didn’t work. So here’s all the files:


    # /etc/crontab: system-wide crontab
    # Unlike any other crontab you don't have to run the `crontab'
    # command to install the new version when you edit this file
    # and files in /etc/cron.d. These files also have username fields,
    # that none of the other crontabs do.
    # m h dom mon dow user  command
    17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
    25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
    47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
    52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )


    # /etc/cron.d/php5: crontab fragment for php5
    #  This purges session files older than X, where X is defined in seconds
    #  as the largest value of session.gc_maxlifetime from all your php.ini
    #  files, or 24 minutes if not defined.  See /usr/lib/php5/maxlifetime
    # stop the email!!
    # Look for and purge old sessions every 30 minutes
    09,39 * * * *  root  [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime) > /dev/null 2>&1

    Any other info you need, or suggestions?