I've tried everything to change the max_execution_time
of a php crawler script so that it can run an infinite amount of time.
I have changed the php.ini file setting max_execution_time
to 0
or 100000000
but with no change
I've also tried setting it from the php script itself by using ini_set('max_execution_time', 0);
All php scripts throw the same error Fatal error: Maximum execution time of 3000 seconds exceeded
, what could I be missing and how can I make sure there is no max execution time limit?
php script
<?php
ini_set('MAX_EXECUTION_TIME', -1);
error_reporting(E_ALL); // turn on all errors, warnings and notices for easier debugging
//ini_set('max_execution_time', 123456);
ini_set('max_input_time', -1);
ini_set('memory_limit', '512M');
set_time_limit(0);
date_default_timezone_set('Europe/London');
/*code which scrapes websites*/
?>
phpinfo()
max_execution_time 0 0
max_input_time -1 -1
Try turning off safe mode in php and then try the below code
This should allow you to run the script for infinite time.
In Apache you can change maximum execution time by .htaccess with this line
set_time_limit() php manual ref.
use
at the top of the script
If you are on windows, and this is a CLI run script maybe read this.
check
phpinfo()
from a temp script and search formax_execution_time
. make sure that it has same value what you are setting. default should be 30 seconds. try to change it to a couple of different values and restart apache then check the value inphpinfo()
to confirm.if when you change the value it is reflected properly in the
phpinfo()
it means that there is some code in your script which is changing this value. search for two things in your code:ini_set()
and check if it is changemax_execution_time
set_time_limit()
these functions can change maximum time limit of execution from script. otherwise you should check
.htaccess
from where this value may be set. but this will effectphpinfo()
also.In WAMP there is three PHP.ini files so you might find 3 in xampp also, so just search for it with find and replace
max_execution_time
to what you are setting. But you must keep something small not too large as for speedy the app you running.You could also try setting
ignore_user_abort(TRUE);
in your script as it might be the browser timing out rather than the script.From the php.net manual
See here for more info
http://www.php.net/manual/en/function.ignore-user-abort.php