Problems with cron file

Thread Solved

Join Date: Jun 2009
Posts: 9
Reputation: julio gomez is an unknown quantity at this point 
Solved Threads: 0
julio gomez julio gomez is offline Offline
Newbie Poster

Problems with cron file

 
0
  #1
Sep 15th, 2009
Hi,
I have a corn.php file that runs automatically every day and one of the functions is to send an e-mail to certain users.
The problem is that the e-mails are being sent twice. I can't find anything wrong with the cron file, but checking the access_log.processed file of the server I found two entries with the cron file runnig at practically the same time:
1)..."HEAD /x/cron.php..."
2)..."GET /x/cron.php..."

I don't know much about apache but I think the problem might be that the HEAD method is also sending e-mails when it runs the file, so my questin is: ¿Can the HEAD method run the php file to send emails?

Thank you
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 72
Reputation: smartness is an unknown quantity at this point 
Solved Threads: 10
smartness's Avatar
smartness smartness is offline Offline
Junior Poster in Training

Re: Problems with cron file

 
0
  #2
Sep 15th, 2009
Where do you get the e-mails from? Mysql?

If yes, then i would suggest:
add a "lastsent" field, and each time you send a e-mail, update that field with a time().

So before you sent emails build a if($lastsent > something) {
do_send();
} else {
walk_away();
}

I don't know if I got you right, but i hope you got me!
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 9
Reputation: julio gomez is an unknown quantity at this point 
Solved Threads: 0
julio gomez julio gomez is offline Offline
Newbie Poster

Re: Problems with cron file

 
0
  #3
Sep 15th, 2009
Thanks for the suggestion, it looks like the problem is solved.
But instead of using if() to select the ones I wanted to send, I used WHERE TIME() > X in the query.

I was trying to understand if the HEAD method was sending the emails and didn't tried to solved it in the cron.php file.
Reply With Quote Quick reply to this message  
Reply

Tags
apache, cron, headmethod

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC