Reputation: 326
In PHP, I want to run a script who need 2 minutes to compute but my max_execution_time is only 30 seconds.
I can't change my max_execution_time in php.ini nor call shell_exec
I already done all the optimization I could think of. Any idea?
Upvotes: 0
Views: 358
Reputation: 41249
You can also set it in your .htaccess file
Add the following line to your .htaccess file
php_value max_execution_time 200
Upvotes: 2
Reputation: 3766
The "best" option you have is to cut your algorithm into smaller part. Each part should execute within 30 second to avoid timeout. Here are few ideas.
Using CURL:
Using CRON task:
Upvotes: 2
Reputation: 2039
Even if you can't change the php.ini
file itself, you might be able to change options via PHP code with ini_set
.
You can also try to call set_time_limit
inside your code, resetting the current time counter (this doesn't work in safe mode).
If that doesn't work, try to split the task up into multiple sub-tasks and save the temporary results, so that you can perform the task on multiple executions and thus bypass the time limit.
Upvotes: 2