Hi, I have a php script that processes large text file 11mb line by line and outputs it on the screen. For some reason,my script just stops after certain period of time. I already did set_time_limit(0) Is there anything else I need to do to extend execution of my script? I host at godaddy. Does godaddy puts some kind of limitation on php script execution? Thanks a lot for your help guys.
Maybe the memory limit. Try increasing it: ini_set('memory_limit', '25M'); PHP: Place also these 2 lines on top of your code to see if there are any hidden errors: error_reporting(E_ALL); ini_set('display_errors', '1'); PHP:
Thank you for you reply guys. If it is Apache timeout,is there any way to override it? I host at Godaddy Linux hosting.
If you're hitting timeouts, it's probably more an indication that your script needs writing more efficiently rather than indicating the timeout is set too low. If you're just outputting the file line by line, why do you need a script? And surely no one is going to look through 11mb of browser page?
Not really. It's there for a purpose. If anything is being processed for longer than 30 seconds, then I think you need to re-evaluate what you are trying to do.
Not true. Most scripts I write requires hours or days of continuous work. It all depends on the data you are working with. Follow these two steps: Increase the timeout variables in php.ini. Run the script from command prompt rather than the browser. Peace,
Whilst its true that you need to evaluate it on a case by case basis - I still think that if it takes an age to run in PHP then PHP is probably the wrong tool for the job! For a start, if you run it from the command line, rather than through a browser, why bother using a web server and web publishing language such as PHP to do it? Wouldn't the task be better accomplished through a 'nix shell script? Or maybe in a different language such as Java? Even if there are core parts that PHP makes real easy (for example, let's say you have a million images that you want to thumbail using GD), I'd still write the majority of that in shell script and just call a php script to do each individual resize rather than expecting my PHP script to stay running for hours and hours. Besides, as the poster stated, all he appears to be doing is dumping an 11mb file and unless there is some other processing going on, that sounds a crazy waste of PHP.
Maybe the server kills the process for a limited time, such as 1 hour or somting. I know NetFirms has this limitation. I don't know if GoDaddy has the limitation too. You may contact with GoDaddy to confirm it. If GoDaddy doesn't have, it should be your setting issue.