The max execution time is set up to be 30.

When I submit the requests of execution through the client browser, it shows the execution was running. It still hung up there after 30 seconds, after 2 minutes ...

And the browser hung there forever.

I have another page which saves the reports of the execution, so I open another browser window, and check out the report. It shows me the execution is still going even after 1 minute, 2 minutes...

Every time, I refresh the report page, it shows me new results of the execution. Finally, after 3 minutes, the report page stops updates, the whole execution was done.

The original browser which I submit the request for this execution still hung up there, it seems the time is running out. It never goes to the next page.

But the execution on the server took 3 minutes and it finished.

Now comes my question:

1) max execution time is 30 seconds. Why the execution on the server run for 3 minutes. And the client browser hung there and run out of time and never went to the next page, but didn't get the time out message?

2) If a loop can run 3 minutes on the server regardless that rhe max execution time is 30 seconds. How can the server knows that if I write a mistake infinte loop and stop the execution by itself? or I write a legtimate loop and that loop takes long time to finish and keep on running?

3) Sometimes, I write a infinite loop and the browser will get the message time runs out, so I will just close the browser. Do I have to go the the server to end the loop activies there or it is already ended?

I am confused here. Any help?

Thanks!

    Quote from the manual:

    ...the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running.

    I think that answers most of your questions.

    The script might have finished (not properly perhaps) and the browser still may show like it's working on something. This could happen for example when a script pops up a window with JavaScript and writes stuff to the window, but forgets to issue the close window command (i.e. windowlabel.document.close()😉. The browser will just keep on working in that case.

      OK, so actually my 3 minutes execution including the time to do the mysql query works etc. so it is not counted as part of the 30 seconds max excution time.

      The time out fatal error will be issued only when the script itself used 30 seconds.

      I have some new quesions here

      1) how about the mail functions? will the time execute mail function is counted as part of 30 seconds or not (just like databaes query, and stream operations not counted)?

      I put the mail functions into the loop, so it will send personal addressing (name, title) e-mail to my newsletter subscribers.

      2) so actually, in my previous case, it was not over 30 seconds limit actually. It finished the whole execution fine except at the end of the execution, the last statement will be header("Location: thankyou.php") to redirect the client browser to the thankyou.php page. But the browser was sitting there and never get redirect, even all the other works that scripts supposed to do are done completely. What could be wrong?

      3) so if i have a loop to loop 5000 times, I may use set_time_limit() functions for every 500 loops, so my big loop will not be timeout before it is finished. Of course the apache and os set up should be considered too.

      Thanks!

        searain wrote:

        how about the mail functions?

        toplay wrote:

        Any time spent on activity that happens outside the execution of the script

        And mail definitely counts for that. Especially if you're using mail() five thousand times in a loop. If you insist on doing that (rather than using an SMTP class, or doing it offline) then you could at least reset the time limit to a few seconds on every pass through the loop.

          Weedpacket wrote:

          And mail definitely counts for that. Especially if you're using mail() five thousand times in a loop. If you insist on doing that (rather than using an SMTP class, or doing it offline) then you could at least reset the time limit to a few seconds on every pass through the loop.

          The max mail sent out is 1000, and if just scripts it finishes in 30 seconds. I am just trying to expect the worst.

          I will check on the smtp class or doing it offline approach. Start from google search.

          But if someone has some good links to suggest here, I will appreciate it.

            Write a Reply...