PHP execution time

Started by proofread, Feb 22, 2023, 03:04 AM

Previous topic - Next topic

proofreadTopic starter

Hi there! I'm having some trouble with PHP:

My script deals with Excel files, and sometimes the files are very large, which causes the script to take a long time to process. As a result, the script exceeds the apache runtime quota, and unfortunately, I cannot increase the quota because my hosting service does not offer that option.

Could you possibly advise me on how to run a PHP script without causing the page to freeze for the user who initiated the script? Is there any way to work around the time limit?


To avoid freezing the page, there are two ways to run a PHP script: via a cron job or by creating a background process. If you want to bypass the quota, you can do so by breaking the task into smaller pieces and running them sequentially from a queue. You can search for pre-existing solutions online by searching for "php background" and "slices."

Alternatively, you can use the following code snippet to ignore disconnection from the user and set an unlimited script execution time:


This will allow the script to continue running even if the user disconnects from the page.


Yes, you can run the script in command line mode to avoid the runtime quota limit. By default, the max_execution_time has an unlimited value of 0.

To launch the script, refer to the Program Launch Functions section of the PHP manual here: