Tuesday, 3 November 2015

on timeouts

I have a webpage (really a script in php) which is munching a lot of data and spits a nice report as a web-page.
Don't ask. It had to be done this way.

That data comes from a very slow source, so the script had to have all sorts of timeouts taken down:

set_time_limit($seconds); 

being the first one. Setting seconds to 0 turns off limits. Use with caution!

Make sure that  this actually will remove execution limit.
Usual setup for php is execution time of the scripts limited to 30 seconds.
If displaying

bool set_time_limit (0);
ini_get('max_execution_time');

What you get isn't 0, then you need to look into changing the php.ini file.
The easiest way to find the location of your php.ini file (if you have access to the console) is running in the command line:

> php --ini

if you don't have access to the shell, then you can always script it by displaying configuration information via:

phpinfo();

Now that you know where to look, locate max_execution_time in it and change to whatever you want it to be. It understands the numbers as seconds. I discourage setting 0 (which will turn it off).

If you can't change your php.ini you might want to create a .htaccess with the following line:

php_value max_execution_time 200

For my needs however I am using wget to actually save the contents of the website to my disk.

That's yet another timeout to take care of. Otherwise wget will timeout, and my script is going to run for minimum 4 hours.

To remove the timeout from wget you need to run it with this parameter timeout set to 0:

> wget --timeout=0


No comments:

Post a Comment

Real Time Web Analytics