I have script that takes long time to execute. In a result server responds in 503 error. How can I set longer execution time?
In my PHP script I set:
set_time_limit(0);
ignore_user_abort(true);
This question is very similar to PHP Background Processes. So read that; In addition,
First you need to change the time limit in php.ini; you cannot change it in the script itself. Or in .htaccess using php_value
Second, you may be you want to modify how you interact with user more friendly so that the page uses an update; you can explore ajax; http-refresh; multipart pages for different approaches. If you are doing long calculations perhaps you can launch them in the background and update a database, retrieve the results later.
Despite what time-limit you set in the script, a web request might time out earlier because the client gives up, or because any proxy server in the middle gives up, or possibly if the apache server is configured to give up.
As the other answerer mentioned; the maximum_execution_time variable might help, but it would be better if you didn't leave the visitor waiting with a long delay.
Consider using a pattern that shows feedback:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With