I'm running a script that takes a few minutes to run. I set the max execution time in php.ini to 3600 seconds but the script still crashes after 8-17 minutes, saying "page cannot be found". I tried running it on 2 different machines more than once on each.

What can I change to keep it from crashing?

Thanks.

    It's not a programming issue. The script works fine. But it takes so long to run that it ends up crashing.

    I'm asking what settings I can change to allow the script more time to finish.

      i think what hes getting at is maybe your script can be refind and inproved upon to make it execute in less time.

      I have faced the same issues my self but have solved the problem in the past by improving upon my code.

        It is a programming issue if its taking very long to run 🙂

        Try also chucking in ignore_user_abort(true) or something.

          Every piece of networking equipment between and including your server and your client PC have timeout settings on them. You can't change them all. So your server might be set up to allo the script to run for an hour, you client PC might be set to wait for an hour for a response, but if your client's ISP's router is set to timeout after 2 minutes, then your client PC is still going to show an error page.

          You may need to think up a different solution to your problem, unless you're working on a controlled (intranet) environment whenre you can configure every single piece of kit in the chain.

            It is a programming issue if its taking very long to run

            It's the amount of data in the database. I'd post the code but it's kind of confidential and long. Sure, I can rework the code but it would take a week and I would still need to work with lots of data and use while loops and the same problem might come up the next day on another script anyway.

            ignore_user_abort(true)

            didn't work.

            I also tried putting in set_time_limit(1000) in all the while loops to keep resetting the max execution time but that isn't working either.

            Is there some setting in Apache server or mySQL I can increase? We are on an intranet. I'm also using XAMPP if that helps any.

              It's not a programming issue. The script works fine. But it takes so long to run that it ends up crashing.

              This doesn't make sense. The script works fine but it crashes? What happens if you run it from the command line? Does it still crash? If it does run from the command line then why not just run it as a cron job and have the result mailed to you or written to a file? The issue is probably browser timeout. Your script runs too long without sending anything to the browser causing the timeout. There's a way around this by sending a little data to the browser every 10 seconds or so. You might want to seach google for browser timeout and how to prevent it.

                1.) Almost everything is a script issue. And no matter what you say: improvement of code can really solve 90% of the problems.

                2.) XAMPP isn't the best choice for an environment that you're going to have lots of load on. You're better off just configuring it yourself piece by piece.

                3.) If you're doing lots of mySQL query stuff, have you optimized the queries? Have you checked the execution time? Is there a way to eliminate some of the while() loops by using predefined mySQL functions (like IN)? Once again, this goes back to code optimization and improvement.

                4.) If you're going to be running this for a long time, and the browser won't refresh, how about an AJAX implementation of it? Let the server do its thing, let the JS wait for a response, and the JS can update the browser every so often with a nice little "Loading" thing.

                5.) Do you mean crash as in "I have to start the system up again" or crash as in the page timed-out or the page can't be displayed? If it's a time-out/display problem, then it's not a crash, and ultimately this can come down to code optimization/improvement. IF you actually do crash your server, you need to rethink what you're doing as far as your code and how you're executing it.

                6.) Nothing is really all that confidential. So we see bits of your code, you can obfuscate it so we see "SELECT a.A, a.C, a.D FROM table1 a, table2 b, table3 c WHERE a.A=b.C AND...." so we don't see the exact query, nor do we know what's returned. Plus, if done correctly, short snippets of the code will never be enough to disclose confidential information about someone or something. I work in the Healthcare field, and HIPPA breaths down our necks all the time. The loop-hole is not saying names or identifying information about the patient. Then you're free to say: "Oh, so this person rolled their car, had their guts lying about, and needed brain surgery, and died on the operating table yesterday." No identifying info, no breach of confidentiality. For all anyone knows, I made it up.

                7.) You want help, but you're not willing to help us by giving us something to go on. For us to help you, we need to see some sort of code. Or some sort of really good description of what you're doing. It doesn't have to be detailed to exactly what info you're pulling, but detailed in that you say how you're pulling it. I don't care what project you're working on. Chances are we'll never meet. But you have to help us, in order to receive help on this board.

                Help me to help you
                Help me to help you
                Help me to help you

                Show me the Code!!
                Show me the Code!!
                Show me the Code!!

                ~Adapted from Jerry McGuire

                  That doesn't solve your problem. That's a work around for now. What happens when a non tech savvy person can't do this and they get that error? What then?

                    We're glad you figured out the browser timeout by yourself.

                      from a programmers point of view that is a "cop out", only cheating your self.

                        I think this is the advantage of developing for an intranet environment instead of a internet environment. You can change any element of chain from client to server. If your script runs slowly, you can change the timeouts on the client PC.

                        This issue could arise again if usage of the slow script increases, if the root cause of the slowness gets worse, if the company decides to allow people to log in from home, or if the company decides to make the service available over the web.

                        Until then, treating the symptoms may seem like a worthwhile approach.

                          Write a Reply...