Remember that PHP has a variable in the ini file that indicates how long the script will run. max-execution-time
Make sure you don't jump to this, or use set_time_limit () to increase the execution time. Does this program work through a web server or through cli?
Addendum: My bad experience with PHP. Looking through some background scripts that I wrote earlier this year. Sorry, but PHP is a terrible scripting language for executing anything over long periods of time. I see that the new PHP (which we have not yet updated) adds functionality to make GC work. The problem I am facing is using too much memory, because the GC almost never starts to clear itself. If you use things that recursively reference them, they will also never be released.
Creating an array of 100,000 elements makes the memory, but then, installing the array in an empty array or splicing all this, DOES NOT release it immediately and does not mark it as unused (also creating a new array of 100,000 elements memory).
My personal decision was to write a perl script, which was maintained forever, and system ("php my_php.php"); when necessary, so that the translator is completely free. I currently support 5.1.6, this can be fixed in 5.3+, or at least now they have GC commands that you can use to force a clean GC.
Simple script
#! / usr / bin / perl -w
use strict;
while (1) {
if (system ("php /to/php/script.php")! = 0) {
sleep (30);
}
}
then in your php script
<? php
// do a single processing block
if ($ moreblockstodo) {
exit (0);
} else {
// no? then lets sleep for a bit until we get more
exit (1);
}
?>
Rahly
source share