...

View Full Version : script exe time



dizyn
11-06-2007, 10:53 AM
Hello all

I want to execute some script for some time like say I want to run a piece of code for around 2 minutes and then stop it is that possible? and if its possible how can i do so using php?

thank you
dizyn

gunman
11-06-2007, 12:58 PM
Did you check set_time_limit() function, i think that it should help you

aedrin
11-06-2007, 04:56 PM
Did you check set_time_limit() function, i think that it should help you

This has nothing to do with the question. Did you even read it?


I want to execute some script for some time like say I want to run a piece of code for around 2 minutes and then stop it is that possible? and if its possible how can i do so using php?

You could use sleep (http://php.net/sleep).

If you need to do something every X minutes, you will need to use cron jobs, or something similar if your server does not allow them.

firepages
11-07-2007, 12:51 AM
sleep() will stop script execution, not quite sure how that makes more sense than gunman's suggestion ?



<?php
set_time_limit(125);
$finish=mktime()+120;
while(mktime() <= $finish){
//DO STUFF
}
?>

aedrin
11-07-2007, 04:45 PM
sleep() will stop script execution, not quite sure how that makes more sense than gunman's suggestion ?


I want to run a piece of code for around 2 minutes and then stop it



<?php
sleep(120);
?>


It's a piece of code that runs for 2 minutes and then stops.

It'd be wrong of me to assume that the user wants to run some calculations/processing code with a time limit of 2 minutes.

firepages
11-08-2007, 12:27 AM
It'd be wrong of me to assume that the user wants to run some calculations/processing code with a time limit of 2 minutes.


say I want to run a piece of code for around 2 minutes and then stop it is that possible?


This has nothing to do with the question. Did you even read it?

did you ?, only the original poster knows what they want, perhaps they will qualify, and perhaps until then you could give others trying to help a break ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum