0

i have a script that load a csv by CURL, once i have the csv it add each of the records to the database and when finished, display the total amount of registries added.

on less than 500 registries, it execute just fine, the problem is that whennever the amount of registries is too big, the execution is interrupted at some point and the browser displays the download dialog with a file named like the last part of my url withouth extension containing nothing. no warning, error or any kind of message. the database shows that it added some of the registries, if i run the script several times it adds a small amount more.

i have tried to look for someone with a similar situation but haven't find it yet.

i would appreciate any insight in the matter, i'm not sure if this is a symfony2 problem, a server configuration problem or what.

thanks in advance

rpalaciosv
  • 73
  • 4

2 Answers2

2

Probably your script is reaching the maximum php execution time which is by default 30 secs. You can change it in the controller doing the lengthy operation with the php set_time_limit() function. For example:

set_time_limit (300); //300 seconds = 5 minutes 
Carlos Granados
  • 11,273
  • 1
  • 38
  • 44
  • You can also try to optimize your loader so that it executes faster :-) – Carlos Granados Sep 05 '12 at 16:52
  • i already considered that, my max_execution_time is set to 600, and i added a set_time_limit(600) inside the for bucle but it won't help. also, no "fatal error : max execution time exceeded..." message appear. I just tested and it appear to be stop after barely 1 minute. – rpalaciosv Sep 05 '12 at 17:04
  • Calling set_time_limit() inside the script will probably eventually break your unit tests, because they will normally run inside a single process. @weyandch's answer is a better option. – Ryan Nov 20 '14 at 05:35
1

That's more a limitation of your webserver/environment PHP is running in.

Increase max_execution_time to allow your webserver running the request longer - alternative would be writing a console command, the cli environment isn't restricted in many cases.

weyandch
  • 644
  • 6
  • 14
  • 1
    Just to comment that the problem was in the zend server CE configuration, it ignores the apache config and set a hard maximum_execution_time of 60 – rpalaciosv May 21 '14 at 03:58