(I saw an interesting post over at acquia.com dealing with long-running cron jobs which inspired this post).
How do I stop PHP timing out when a script takes too long?
A. PHP places resource limits with these 3 commands:
=> max_execution_time : Maximum execution time of each script, in seconds (default 30 sec)
=> max_input_time : Maximum amount of time each script may spend parsing request data (60 )
=> memory_limit : Maximum amount of memory a script may consume (default 8MB)
You can increase the resource limits so that your scripts have more time to run:
Open /etc/php.ini (or /etc/php5/php.ini) file:# vi /etc/php.ini
Setup new resource limits:max_execution_time = 600
max_input_time = 120
memory_limit = 64M
Restart Apache or lighttpd web server:# /etc/init.d/httpd restart
OR# /etc/init.d/lighttpd restart
Note: If you are running in a shared hosting environment then PHP may be set to SAFE mode, which will mean that you cannot alter your php.ini file. In this case you will have to ask your host to make the changes for you. If they won't change it, then perhaps it is time to change hosts...

0 comments:
Post a Comment