About max execution timeout

1.8k Views Asked by At

I have some question on server response max execution timeout.

If, I called server API to running something huge and not able to finish within time limit set in server php.ini max_execution_time config, will the process in server still continue to process? - if so, will it process endless? - if not, is the process stop immediately or canceling loop one by one and finish all process.

In my experience, when I receive max execution timeout on local hosting, the data is already process.

So I not sure it is because it is stuck on response until timeout or server is continue running after throw max execution timeout exception.

4

There are 4 best solutions below

0
buckyBadger On

It doesn't continue after the exception is thrown. It's simply cut when the time is up.

Anything before the time out is executed. If not designed especially to precent this.

1
Nikola Petkanski On

It really depends on what your PHP code is like.

Usually the code execution will halt. You can alter this behaviour using ignore_user_abort().

1
Paun Narcis Iulian On

PHP interpreter runs scripts against php.ini configuration and checks max_execution_time = 500 and max_input_time = 500.

PHP doesn't continue to run the script after the max_execution_time. It's simply "kills" the script.

What can also happen, script starts a database query, normally query will run on database server until finished no-matter what happens to the script. Also you may get a Gateway Timeout coming from the web server, for Apache check httpd.conf and look for the setting Timeout.

If you need to run a script that takes time to execute, a lot more then the rest of your website, you should call a web page, PHP on server, fork a new process as a background executed script (the PHP part that takes lot of time), inform user via async status updates or sending an email that processing ended. You should not extend max_execution_time for all script just for one exception.

0
shafrianadhi On

The process won't continue and stop immediately after the time limit set in server php.ini max_executiontime config has been reached then php throw a max execution timeout exception.

Here (How to increase maximum execution time in php) if you want to increase maximum execution time in php file.