Jump to content

Script stops after 5h36: no error.


B0b

Recommended Posts

Hey guys,

 

I really rely on you for that one, I got no clue what's wrong.

I have a script which needs to run for several hours, and it stops at some random moments without echoing any error.

The script is made so a message will appear at the end and the following was used to show any error:

 

ini_set( 'display_errors', '1' );
error_reporting( E_ALL );
ignore_user_abort( true );
set_time_limit( 0 );

 

In lower bottom of the page, it shows "Finished", nothing special echoed.

 

The script could look like:

 

for ( $i = 0; $i <= 99999999; $i++ )
{
    echo 'Foo Bar' . $i;
    flush();
}

echo 'Finished';

 

What could cause the above script to stop?

 

I am using DirectAdmin.

 

Thanks so much.

Link to comment
Share on other sites

It does not exit the loop and echo finished... Thus the problem.

 

Impossible to say what the problem may be. If it is not reaching the end, then it is likely there is an error encountered in what is taking place in the loop. You didn't provide any details, but I have to assume the loop is processing data. Could be there is a problem with some of the input data that the script is not handling correctly. You should implement some logging to help pinpoint the problem. At the very least you could log the value of $i (or whetever your real counter is) so you will know what the last record processed is. Or you could go further and log the actual data being processed - if that is feasible.

 

However, it would be interesting to know exactly what your processing consists of. If any script is taking more than 5 hours to finish, then even the smallest performance improvements can reap huge benefits.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.