Is it possible to set maximum execution time of exec($command)
function? Sometimes execution of my $command
lasts too long stopping after 1 minute and presenting this error:
Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\files.php on line 51
How can I increase the exec()
command maximum execution time?
if (allow()) {
exec($command);
if (file_exists($file)) {
//exec($makeflv);
echo '<script language="javascript" type="text/javascript">window.top.window.aviout(1);</script>';
} else {
echo $error;
}
} else {
echo $error;
}
See http://php.net/manual/en/function.set-time-limit.php
set_time_limit($seconds)
If $second
is set to 0
, no time limit is imposed. Note that you should be cautious with removing the time limit altogether. You don't want any infinite loops slowly eating up all server resources. A high limit, e.g. 180
is better than no limit.
Alternatively, you can adjust the time setting just for certain blocks of code and resetting the time limit after the time critical code has run, e.g.
$default = ini_get('max_execution_time');
set_time_limit(1000);
... some long running code here ...
set_time_limit($default);
In .htaccess
you can set these values:
php_value max_execution_time 1000000
php_value max_input_time 1000000
You can also try this at the top of your PHP script:
set_time_limit(0);
you can use ini_set()
like this:
ini_set('max_execution_time', 0);
Setting it to 0 will make your script run forever according to the documentation of the ini-directive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With