I have a script that will take a few hours to finish running. The problem is that after 10 minutes the script is stopped due to timing out in Apache I'm asssuming. I have hostgator as a host and they refuse to let me change the timeout settings for Apache or PHP. How can I let this script finish running and not have Apache timeout and stop it? I've even tried running the script from the command line using a cron job and it just times out after 30 seconds which is the PHP timeout limit. When I run the script in the browser it seems to be able to bypass this limit but then runs into the 10 minute Apache limit. I'm assuming I need some way for the page itself to be "done" loading while the script continues to run and then the page refreshes and shows the new output or something like this. This is driving me INSANE. Please help.
PHP automatically disables the time limit when running in command line mode, are you sure this is the error? Try. set_time_limit(0); PHP:
Yes I spoke with hostgator and they said there is a 30 second maximum execution time for PHP and it can't be changed. I had my script output to an html file that had a meta refresh in it then I created a cron job to run it. I watched the output file refresh every 5 seconds for 30 seconds then stop. When I run the script in the browser it runs completely fine for exactly 10 minutes. I already have set_time_limit(0); in the script.
A few hours?! Have you thought about breaking the php script up and creating an Ajax script to call the php each time it finishes a part?
set_time_limit(int $seconds) -------- Best To Increase the Value Of $seconds --------------------------------------------------------------------------- Download Free Ebooks of Java, Linux, ASP.NET, PHP, VB.NET Smart Banking Tips
You can also edit php.ini: ... max_execution_time = 60 ; Maximum execution time of each script, in seconds max_input_time = 60 ; Maximum amount of time each script may spend parsing request data ...
^^ Looks like neither of you even read the thread because I already said I have set_time_limit(0); and that my host has locked the max execution time. Please read before responding next time. Not trying to be rude or anything but don't just respond without understanding the situation because it makes you look like a post whore. I'll look into this but it's kind of difficult as the script only really breaks up into different parts that could take over 10 minutes to complete.
If you don't want to edit the script then I guess you'd have to change hosts. a few hours is a very long time, surely you can break it up a bit, what does it do?
Move the script to a host that will allow the script to finish ? If Hostgator has disabled your ability to extend script execution times, and you do find some sort of workaround, you're probably going to run into problems along the lines of your account being suspended or being right back where you are now when their administrators start wondering why there's lingering processes slowing down their servers and trace it back to you.
The solution can be to rewrite the script dividing it into fast accomplished parts. The parts can call each other so the process does not stop. Or find another hosting provider, maybe switch to VPS plan.