homepage Welcome to WebmasterWorld Guest from 54.166.110.222
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Problem with maximum execution time
Jakotsu




msg:3433662
 9:01 pm on Aug 27, 2007 (gmt 0)

I need to run a script which will take several minutes to complete, but the max execution time is 30 seconds and I cannot change that value.

Is there some way to detect the elapsed execution time of a script, in order to suspend it automatically and prevent the timeout?

Thanks in advance!

 

vincevincevince




msg:3433882
 2:47 am on Aug 28, 2007 (gmt 0)

set_time_limit(0); removes the limitation altogether
set_time_limit(X); sets the time limit to X

To detect run-time, use something like this:

<?php
$start=time();
while (($long_slow_loop)&&(time()<($start+25)))
{
...
...
}
?>

The 25 allows 5 seconds spare, you may wish to cut it finer depending on how fast your loop runs.

Jakotsu




msg:3434591
 6:01 pm on Aug 28, 2007 (gmt 0)

Thanks, I'll try that.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved