Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP set_time_limit no effect

I have a very painful slow script that gets lots of data from MySQL and creates a large report out of it that it serves to the user at the end as application/force-download.

Long story short, on production server it keeps terminating after about 30 seconds (quite consistently) and spitting out an empty file instead. On development server it works fine, but it does take significantly longer to execute - about 90 seconds. Just to be 'safe', I set my php.ini file to max_execution_time = 2000 and also run set_time_limit(4000) in the beginning of my script (numbers way over the expected completion time, but just to be sure ;)).

What could be causing my web server to ignore the time limits I set and quit on me after only 30 seconds?

Edit: one thing I know for sure is that it takes MySQL portion of the code 8-9 seconds to complete, and it successfully gets past that point every time.

like image 633
SaltyNuts Avatar asked Sep 05 '25 03:09

SaltyNuts


1 Answers

Maybe the PHP safe_mode.

Try to do a

die(ini_get('max_execution_time'))

to read the value after you have called the set_time_limit(0); to see if actually it get overwrited.

If it gets overwrited to 0 and your script still dies then the cause could be somewhere else in your code

like image 59
dynamic Avatar answered Sep 07 '25 23:09

dynamic