following
following

Reputation: 137

PHP set_time_limit() does not work, safemode is off

I try to disable the time limit in an PHP script by

set_time_limit(0);

but it does not work; the script is still aborted after the system default of 30 seconds. The max_execution_time setting - as displayed by phpinfo() after set_time_limit(0) - still shows 30 seconds for both Master and Local value. It also shows that Safe Mode is Off.

Do you have any idea what goes wrong? It's PHP 5.3.3 (cli) running on CentOS 6.2 with Apache 2.2.15.

Upvotes: 2

Views: 7694

Answers (2)

Eloy Ruiz
Eloy Ruiz

Reputation: 767

I was uploading a CSV file with lots of rows to process and it was max_input_time the problematic value. The solution is quite easy:

ini_set('max_input_time', $yourDesiredValue);

$yourDesiredValue should be equal or bigger than max_execution_time.

Upvotes: 0

following
following

Reputation: 137

I was able to solve the problem now. The reason was

php_admin_value max_execution_time "30"

... within the virtual host configuration. If set there, the time limit cannot be overridden by a PHP script. And the solution is to set it either in the php.ini instead of Apache config - that allows override ...

max_execution_time = 30

or to define exceptions for certain directories within the apache config, e.g.

<Directory /path/to/my/scripts>
  php_admin_value max_execution_time "600"
</Directory>

I also tried to define exceptions for single files using the <Files> directive, but that did not work.

Upvotes: 4

Related Questions