Stop cron jobs from emailing

i have a cron job setup that runs 4 times a day, it runs a .php page to update a mysql database. but it emails me everytime it runs, which i really dont need to do.

is there anyway to set it up so it wont email me, not even on errors, because the php script is setup to record an error if one should occur.

i know you can set the global variable MAILTO, but if i set this up as an erronious email will it not send an email, or will it try to send a failed email attempt through mail deamon?

cron will only mail MAILTO if the script produces output. So the key is to make the script suppress output by just doing output redirection to /dev/null. just add:

>/dev/null 2>&1

to the end of the script to make all output go to /dev/null. That should do it.

Chris

thanks, that looks like it worked… i did a wget -O /dev/null and that didnt seem to work, but the redirect and error redirect to null seems like it worked…

thanks again for your time, very prompt and accurate reply!

I’m having a very odd cron issue. We have a job that runs a php file once a day. However, every time the cron job runs, it creates a file named the same as the php file we’re running in our main account directory: /home/account/

So, for example we’re running:
30 0 * * * wget http://www.ourdomain.com/tasks.php > /dev/null 2>&1

That file is located at: /home/account/ourdomain.com/html/tasks.php

After a few days we end up with following in our account’s root directory: /home/account/tasks.php, tasks.php.1, tasks.php.2, etc…

The contents of each one of the tasks.php file is:
>> Connecting to: support@designchemistry.com@mail.designchemistry.com
>> Closed connection to: support@designchemistry.com@mail.designchemistry.com

How do I get this file to stop being generated?? It appears the /dev/null is doing nothing but keeping an e-mail from being sent.

Hi,

That’s just the way wget works by default, it creates the file that’s downloaded, and if the file is already there, it renames it .1, .2, etc. Try using the -O - parameter to wget, to specify stdout (the screen) as the place to write the file contents (which you have redirected to null)

30 0 * * * wget -O - http://www.ourdomain.com/tasks.php > /dev/null 2>&1

Paul

That worked! Thanks so much!