doni49 Posted February 5, 2008 Share Posted February 5, 2008 This is one of those questions that could fall under one of several categories. So I'm not positive which forum to post this in but here goes.... I use a hosting service with CPanel access. I have a PHP script set up to run via CRON. My understanding is that if the PHP script has no output (or any error messages) then the CRON daemon won't send an email message. If there is any output--if the script uses the print function for instance or if there is an error--then the CRON daemon will send an email to the admin. This is the email message that I've been receiving from the CRON daemon: X-Powered-By: PHP/5.2.4 Content-type: text/html Yes--that's the ENTIRE message body. I checked the script there are NO print/echo statements (I even used the editor's find option to look for it in case I was just overlooking it). Anyone have any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/89609-cron-job-weird-email/ Share on other sites More sharing options...
MishieMoo Posted February 5, 2008 Share Posted February 5, 2008 Firstly, it will send an email if you have one entered, no matter what else happens. It will not email you the results of the cron. You should look at some other page to see that. If you don't want to receive an email put :blackhole: in the email box. Secondly, in order to receive an email from a cron you should setup a mail() function in the script that sends you the results of the script. Quote Link to comment https://forums.phpfreaks.com/topic/89609-cron-job-weird-email/#findComment-459148 Share on other sites More sharing options...
doni49 Posted February 6, 2008 Author Share Posted February 6, 2008 I'm sorry but that just doesn't fit with the experience I've had. I don't know--maybe I've got something going on that's strange. For the past couple of years, I've had a cron job that runs every five minutes. The only time it sends an email message is when it had trouble and gives an error message. Also when I was developing my scripts, I was able to print a variable just like I would if I were browsing to my script. I'd wait a few minutes for my script to run and the email would arrive showing me the variables. Based on what you described, I'd receive nearly 300 messages EVERY day--even if there was no problem. That wouldn't make sense. And it wouldn't make sense to send all cron messages to the black hole either--then you wouldn't know if there was a problem. The only issue I'm having now is why in the world is it sending messages that look like this all of a sudden. Quote Link to comment https://forums.phpfreaks.com/topic/89609-cron-job-weird-email/#findComment-459336 Share on other sites More sharing options...
doni49 Posted February 6, 2008 Author Share Posted February 6, 2008 Ok found it. The -q flag suppresses HTTP header output. As long as your script itself does not send anything to stdout, -q will prevent cron from sending you an email every time the script runs. For example, print and echo send to stdout. Avoid using these functions if you want to prevent cron from sending you email. http://www.modwest.com/help/kb5-125.html Quote Link to comment https://forums.phpfreaks.com/topic/89609-cron-job-weird-email/#findComment-459486 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.