Cron Daemon emails when php script finsihes?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Deseree
Forum Commoner
Posts: 84
Joined: Mon Feb 13, 2006 11:35 pm

Cron Daemon emails when php script finsihes?

Post 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
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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)
Deseree
Forum Commoner
Posts: 84
Joined: Mon Feb 13, 2006 11:35 pm

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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..)
Post Reply