php is not the right tool for this. a cron job that runs a php script would be better.
but perhaps something like this would kind of work
Code:
$delay = 10; //seconds
$timeout = 30;//timeout in seconds
$function = 'functionName';//name of function
$force = true;
while ($force){
set_time_limit ($timeout); //reset the timeout counter
sleep ($delay); // wait a while
$function(); // run the function
}
make sure that $timeout > $delay
and also bear in mind that this script is going to be very difficult to cancel once it starts. you'll have to kill the php process. or perhaps add a filesystem check into the loop so that you can at least create a kill file if needs be.
You are right jpadie,
but I need to send email to my 1500 newsletter subscribers, my code must loop and retrieve the email addresses form the database and send first 100, then the code must stop for 5 seconds and retrieve the next 100 etc ... , to give the SMTP server a considerable chance to flush some memory.
any idea?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.