Re: Cron php & refresh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sunday 20 April 2008, Jeffrey wrote:
> I'm working on an application that includes e-mail notifications of
> certain events. Because the application will have hundreds or thousands
> of users, I've designed it so that e-mail notifications are saved to a
> MySQL table. Then a regular cron job runs a php page to select the data
> from the table, put it into a mail() command and mail.
>
> My original vision was to have the script do about 50 mails, then pause
> for a 5 seconds, do a meta refresh and run through another 50 and so on
> - with experimentation in numbers as necessary. This process was set up
> because I recall reading somewhere - perhaps the manual - that it is not
> a good thing to run too many php mail()s in succession. Also, I worry
> about php time-outs.
>
> If you know more about PHP and 'nix than I do, you already realise the
> fatal flaw here: meta refresh doesn't work on a cron job.
>
> Question: is there an alternative? I appreciate I could use sleep()
> after every 50 mails - but there would still be the time-out problem.
>
> I've searched the manual and via Google - but haven't found anything -
> possibly I am searching on the wrong terms.
>
> Your help will be much appreciated.

Why not just have the cron task itself run every 5 minutes?  Every 5  minutes, 
hit a PHP script that will pull the next 50 messages to send and send them, 
then exit.  In 5 minutes minus the time that takes, cron will fire your 
script again.  Problem solved.  

-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux