Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase maximum execution time in php [duplicate]

People also ask

How can I increase the maximum execution time of a PHP script?

To increase the script execution time, you can use the following snippet at the top of your script. ini_set ( 'max_execution_time' , '300' ); In the above example, it would set the max_execution_time directive to 300 seconds.

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.


ini_set('max_execution_time', '300'); //300 seconds = 5 minutes
ini_set('max_execution_time', '0'); // for infinite time of execution 

Place this at the top of your PHP script and let your script loose!

Taken from Increase PHP Script Execution Time Limit Using ini_set()


use below statement if safe_mode is off

set_time_limit(0);

Use the PHP function

void set_time_limit ( int $seconds )

The maximum execution time, in seconds. If set to zero, no time limit is imposed.

This function has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the php.ini.


You can try to set_time_limit(n). However, if your PHP setup is running in safe mode, you can only change it from the php.ini file.