Is there a way to timeout a function? I have 10 minutes to perform a job. The job includes a for loop, here is an example:
Before starting into the loop, set a variable that remembers the time(). At the end of each iteration, check if the current time() is more than 60 seconds greater. If so, break. For instance:
$value){
some_function($key, $value); //This function does SSH and SFTP stuff
if (time()-$startTime>60) break; //change 60 to the max time, in seconds.
}
?>