PHP Execution Time
Posted: Tue Dec 28, 2010 10:55 am
Hi, I'm setting up a site for a client of mine that regularly needs to retrieve information from another website using cUrl. It then uses this information to update records in a database (MySQL). The time it takes to retrieve this information and then update the associated record averages out to about 2 seconds. The problem I'm running into is that there's 16,000+ records in the database and it will grow. Doing the math, this script should take just under 9 hours to execute. Since the hosting site sets the maximum execution time for a PHP script to 30 seconds (and doesn't allow it to change), I have set the script to track the execution time as it loops through and once the script has been running for 15 seconds, it breaks the loop, uses JavaScript to issue a window.location.reload() and then picks up where it left off.
This works, but I'm not satisfied that it's the best solution. I like the idea that the script will pick up where it left off, I don't like the idea of an entire page refresh, and there's always the possibility that the cUrl will hang for longer than 30 seconds and the script will end before it gets a chance to hit the break code. I was told an Ajax load bar is the way to go, but when I search for one, I don't find anything that will help with my situation and I'm not an Ajax expert by any means.
Thanks in advance.
Jason
This works, but I'm not satisfied that it's the best solution. I like the idea that the script will pick up where it left off, I don't like the idea of an entire page refresh, and there's always the possibility that the cUrl will hang for longer than 30 seconds and the script will end before it gets a chance to hit the break code. I was told an Ajax load bar is the way to go, but when I search for one, I don't find anything that will help with my situation and I'm not an Ajax expert by any means.
Thanks in advance.
Jason