Script Doesnt Run All the Way Through

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-04-15T20:03:17Z Indexed on 2010/04/15 20:13 UTC
Read the original article Hit count: 131

Filed under:

I have a php script that should execute 2 for loops. Both take awhile to run. I have called ignore_user_abort(true) and set_time_limit(0). The interesting thing is, the first for loop completes, then the script dies without calling the next line of code.

ignore_user_abort(true);
set_time_limit(0);
for($i=0; $i<10500; ++$i) {
    //do work
}
mail('[email protected]', 'First loop done', 'None');
for($j=0;$j<12500; ++$j) {
    //do work
}
mail('[email protected]', 'Second loop done', 'None');

The first loop will finish after about 20 minutes, but the mail function is never called, the script just ends. Any ideas why this might be happening other than a timeout (I have run other scripts for days on my current configuration)?

© Stack Overflow or respective owner

Related posts about php