CGI Application Timout

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
icarpenter
Forum Commoner
Posts: 84
Joined: Mon Mar 07, 2005 8:12 am
Location: Kent, England

CGI Application Timout

Post by icarpenter »

Hi... I'm not shure if this is a PHP thing or not but I am running quite an intensive script which keeps timeing out...I have tried altering what is the CGI Timeout in IIS to no avail...is there anything I need to do in PHP.ini.

I am using XP and IIS 5.1.

Thanks Ian.
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

The php timeout can be changed in the php.ini, or you could try changing your code to make it run faster :)
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Some scripts have the nature of taking a long time to finish. In that case, use:

Code: Select all

set_time_limit(0);
For an unlimited time limit, or replace 0 with whatever amount of seconds you want to pass before the script times out.

More information here: http://us2.php.net/manual/en/function.s ... -limit.php
User avatar
icarpenter
Forum Commoner
Posts: 84
Joined: Mon Mar 07, 2005 8:12 am
Location: Kent, England

Post by icarpenter »

Thanks for that I have tried this but it still keeps timing out after about 4 minutes...This could be an IIS thing I guess.

I'm going to try moving over to Apache to see if the result varies...

It seems to me that the server is dropping the connection but I cant seem to extend the CGI timout function??? 8O
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Try making it a command line script... When you operate from the command line, you get to see the output as it comes. It requires a bit of modification (no HTML) but it's pretty good for very long tasks.
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

You'll need to look in the IIS configuratio. Apache is normally configured to timeout after 5 minutes and this server time-outs trumps the PHP timeout, so you;ll have to increase the server's timeout in order for the PHP one to take effect.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Yup. Exactly. So command line bypasses Apache and lets you do the script an arbitrary amount of time.
User avatar
icarpenter
Forum Commoner
Posts: 84
Joined: Mon Mar 07, 2005 8:12 am
Location: Kent, England

Post by icarpenter »

Got it...

I upgraded to apache and increased the timeout from 300 to 9999. incidently this feature didn't seem to work in IIS.

I think I will try to run this script from the command line in the future as the output could be more helpfull...

Thanks all!
Rgds Ian. :D
Post Reply