crontab question

Post here if you are having problems with your account or web site.

crontab question

Postby MasterZ on Tue May 30, 2006 6:05 am

I setup a crontab to run a php script every 2 hours. It works, but every time it runs I get an email that says

X-Powered-By: PHP/5.1.4
Content-type: text/html

The command that I am running is

php public_html/zenorsoft/EasySite/reset.php

How can I make it not send me the email? Besides removing my email from the cron output. Is there a way for it to only send me errors?

Thanks.
MasterZ
Registered User
 
Posts: 20
Joined: Tue Jan 10, 2006 7:59 pm

Postby Bigwebmaster on Tue May 30, 2006 6:24 pm

The problem I believe is that your script is outputing some kind of data (ie: 'Content-type: text/html' would count as some data). So for instance if you were to run the script directly from the command line you would see some kind of output on your display after running the command. Whenever this happens you are going to get an email like that when you run it using a crontab.

So there are two ways to fix this. The first way would be to make sure you script does not output any data of any kind. If that is too much work an alternative way would be to setup your crontab like this:

php public_html/zenorsoft/EasySite/reset.php > /dev/null 2>&1

That would make so that all of the output would be trashed. Let me know if this fixes your problem.
Last edited by Bigwebmaster on Tue May 30, 2006 6:30 pm, edited 1 time in total.
UNFLUX.NET SUPPORT
User avatar
Bigwebmaster
Technical Director
 
Posts: 109
Joined: Sun Jun 27, 2004 10:54 pm

Postby MasterZ on Tue May 30, 2006 6:30 pm

hmmm, there was only one echo statement but it was in a for loop that doesn't usually run, and when I go to the file itself it displays no text. I removed the echo statement and I will have to see if it resends the email. I'll have to either wait for it to do it itself, or finish what i'm doing now then change the time it runs.

I'll let you know if it works or not.

Thank you.
MasterZ
Registered User
 
Posts: 20
Joined: Tue Jan 10, 2006 7:59 pm

Postby Bigwebmaster on Tue May 30, 2006 6:39 pm

When you run the script is it doing what its supposed to be doing other than outputing the data you don't want? Is it actually "resetting" something like you are wanting and did you verify that? Sometimes people run scripts thinking they are working, but in fact they are not working and that could cause output to be sent to standard output. That would trigger an email from crontab as well.
UNFLUX.NET SUPPORT
User avatar
Bigwebmaster
Technical Director
 
Posts: 109
Joined: Sun Jun 27, 2004 10:54 pm

Postby MasterZ on Tue May 30, 2006 6:41 pm

I tested that it's actually working. It's reseting several tables in MySQL.
MasterZ
Registered User
 
Posts: 20
Joined: Tue Jan 10, 2006 7:59 pm


Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests

cron