Page 1 of 1
Cron Daemon emails when php script finsihes?
Posted: Fri Apr 14, 2006 1:36 pm
by Deseree
Hey fella's,
I added a php script to cron and every time it finishes, it ouputs the ENTIRE results in my EMAIL, and well, it's BIG freaking files, I'm thinking that it hurts my server to email these, and I don't want it to email me.....
so what should I do to make it so the output is discarded?
0 * * * * /usr/bin/php /path/to/script/script.php > /dev/null
is the "> /dev/null" something I should add and what eXACTLY will that do?
Thank you. Main thing Is I want my server to stop emailing the entire output of the script
Posted: Fri Apr 14, 2006 3:32 pm
by BDKR
The system is only going to email what the script puts out.
In other words, if there is no output to stdout, there is no email with output correct?
Another thing to check is the "MAILTO" element in your crontab.
Posted: Fri Apr 14, 2006 5:31 pm
by timvw
And what happens with stderrr?

I redirect it to stdout.. which goes to /dev/null

Here's an example of my crontab:
0 0 * * * /home/users/timvw/bin/chmoder.sh > /dev/null 2>&1
# * * * * * *
# | | | | | |
# | | | | | +--------- command to be executed
# | | | | +---------------- day of week (1 - 7) (monday = 1)
# | | | +------------------- month (1 - 12)
# | | +---------------------- day of month (1 - 31)
# | +------------------------- hour (0 - 23)
# +--------------------------------------- min (0 - 59)
Posted: Fri Apr 14, 2006 11:22 pm
by Deseree
timvw wrote:And what happens with stderrr?

I redirect it to stdout.. which goes to /dev/null

Here's an example of my crontab:
0 0 * * * /home/users/timvw/bin/chmoder.sh > /dev/null 2>&1
# * * * * * *
# | | | | | |
# | | | | | +--------- command to be executed
# | | | | +---------------- day of week (1 - 7) (monday = 1)
# | | | +------------------- month (1 - 12)
# | | +---------------------- day of month (1 - 31)
# | +------------------------- hour (0 - 23)
# +--------------------------------------- min (0 - 59)
ok great, so > /dev/null
is the RIGHT thing to do, and my script will run 100% no problem, and things like curl, file_get_contents, fopen, fwrite, fputs, all these will still work right? It's just the echo "" stuff that will go to /dev/null correct?
Also,
differernce between
/dev/null
and
/dev/null 2>&1
please?
~Des
Posted: Sat Apr 15, 2006 2:22 am
by timvw
well, if you do > /dev/null everything that is on the standard output device will go to /dev/null (instead of displaying on your shell or being e-mailed to you if there is no shell)
If php reports errors are warnings this will go to the standard error device, and you'd still recieve e-mails

so you send everyting from the stderr to stdout (2 > &1).. And since stdout goes to /dev/null it's all quiet...
Now you have to be sure nothing can/will go wrong (since you won't be notified..)