Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase max execution time for php

I have added set_time_limit(0); function to increase execution time but its executing only 2-3 minutes maximum.

error_reporting(E_ALL); error_reporting(1); set_time_limit(0); 

I want to search links from a site which is taking a long time.

like image 858
Bajrang Avatar asked Oct 12 '11 12:10

Bajrang


People also ask

How do you increase the maximum execution time of 30 seconds exceeded?

Log in to cPanel using your credentials. Navigate to the Software section and click on the MultiPHP INI Editor. In the new window, select your domain from the dropdown menu, locate the max_execution_time PHP directive, and change the value associated with it to 300.


2 Answers

PHP file (for example, my_lengthy_script.php)

ini_set('max_execution_time', 300); //300 seconds = 5 minutes 

.htaccess file

<IfModule mod_php5.c> php_value max_execution_time 300 </IfModule> 

More configuration options

<IfModule mod_php5.c> php_value post_max_size 5M php_value upload_max_filesize 5M php_value memory_limit 128M php_value max_execution_time 300 php_value max_input_time 300 php_value session.gc_maxlifetime 1200 </IfModule> 

If wordpress, set this in the config.php file,

define('WP_MEMORY_LIMIT', '128M'); 

If drupal, sites/default/settings.php

ini_set('memory_limit', '128M'); 

If you are using other frameworks,

ini_set('memory_limit', '128M'); 

You can increase memory as gigabyte.

ini_set('memory_limit', '3G'); // 3 Gigabytes 

259200 means:-

( 259200/(60x60 minutes) ) / 24 hours ===> 3 Days 

More details on my blog

like image 153
Sumith Harshan Avatar answered Oct 16 '22 23:10

Sumith Harshan


Add these lines of code in your htaccess file. I hope it will solve your problem.

<IfModule mod_php5.c> php_value max_execution_time 259200 </IfModule> 
like image 39
Salman Aslam Avatar answered Oct 16 '22 22:10

Salman Aslam