Die/exit/close script execution after 10 seconds ?

Started on the old forum in March 2012 · view the original in the archive · old links redirect here

7 replies · 567 views · started 14 years ago · 1 min read

3 participants
just_m3. Developer · 199 posts #1

i need such code to force php script execution to close after 10 seconds 😒 got some bugy php class for gif resize and on some' of them it keeps you waiting 'till maxim execution time is exceeded x_X don't tell me to set maxim execution time to 10 seconds because my server ignore settings like ini_set or php.ini ... .htaccess

it is possible to make such function based on session or something ?

please share some thots here 🙂 . 😊 tnx ya '.

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

GumSlone Administrator Principal · 1,690 posts #2
set_time_limit(10);

Does it work?

Added after 3 minutes:

or something like this:

$start = time();
for(;;){
	if((time()-$start)>=10) exit("FINITO!");
}

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

just_m3. Developer · 199 posts #3

FINITO! 😁 hell ya ! 💃

Tnx a lot .. 😊 😊 😊 😊

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

something else Fellow · 2,296 posts #4

GumSlone wrote: or something like this:

$start = time();
for(;;){
	if((time()-$start)>=10) exit("FINITO!");
}

Will this cause execution time always to be 10 seconds? (infinitive loop)

GumSlone Administrator Principal · 1,690 posts #5

something else wrote: Will this cause execution time always to be 10 seconds? (infinitive loop)

well you have to place your code into the loop, it depends on what type of code you place inside it, for example if you try to convert a big video file (conversion time of which is much longer than 10 seconds) this will not work, but if you for example want to grab multiple files or do some multiple short similar processes this will work.

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

just_m3. Developer · 199 posts #6

GumSlone wrote: well you have to place your code into the loop, it depends on what type of code you place inside it, for example if you try to convert a big video file (conversion time of which is much longer than 10 seconds) this will not work, but if you for example want to grab multiple files or do some multiple short similar processes this will work.

yup 🙂 already done that 😛 , it works , but i've got to make some mods there , anyway tnx for the idea ! , and yeah the code must be in the loop .. .

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

something else Fellow · 2,296 posts #7

so something onlines of:

$loadgif = false;
$start = time(); 
for(;;){  // for loop has to be above the loadgif function or it wont get executed? ... or will this cause loadgif not to be executed?
    if((time()-$start)>=10) exit("FINITO!"); 
    if($loadgif!=false) break;
} 

$loadgif = loadgif();
GumSlone Administrator Principal · 1,690 posts #8

only this will work

$loadgif = false;
$start = time(); 
for(;;){
    $loadgif = loadgif();
    if((time()-$start)>=10) exit("FINITO!"); 
    if($loadgif!=false) break;
} 

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close