B0b Posted March 22, 2010 Share Posted March 22, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196088-script-stops-after-5h36-no-error/ Share on other sites More sharing options...
oni-kun Posted March 22, 2010 Share Posted March 22, 2010 Why on earth are you flushing 90 million times? Quote Link to comment https://forums.phpfreaks.com/topic/196088-script-stops-after-5h36-no-error/#findComment-1029861 Share on other sites More sharing options...
salathe Posted March 22, 2010 Share Posted March 22, 2010 What could cause the above script to stop? It will stop after reaching 99999999. Quote Link to comment https://forums.phpfreaks.com/topic/196088-script-stops-after-5h36-no-error/#findComment-1029936 Share on other sites More sharing options...
B0b Posted March 22, 2010 Author Share Posted March 22, 2010 This is just an example to show the script cycles through a simple loop like this and will not reach the "echo 'finished'". Quote Link to comment https://forums.phpfreaks.com/topic/196088-script-stops-after-5h36-no-error/#findComment-1029986 Share on other sites More sharing options...
phant0m Posted March 22, 2010 Share Posted March 22, 2010 Why shouldn't it reach the end? At one point in time, it will exit the loop and echo finished, as it did for you. In your case, that was after 5 hours Quote Link to comment https://forums.phpfreaks.com/topic/196088-script-stops-after-5h36-no-error/#findComment-1029990 Share on other sites More sharing options...
B0b Posted March 22, 2010 Author Share Posted March 22, 2010 It does not exit the loop and echo finished... Thus the problem. Quote Link to comment https://forums.phpfreaks.com/topic/196088-script-stops-after-5h36-no-error/#findComment-1029994 Share on other sites More sharing options...
Psycho Posted March 22, 2010 Share Posted March 22, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196088-script-stops-after-5h36-no-error/#findComment-1030000 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.