Apache 2.2 CGI timeout configuration
I have a default Apache 2.2 system setup with a Perl CGI script directory configured like so:
ScriptAlias /jarvis/ "/opt/jarvis/cgi-bin/"
Nothing fancy in here except one of my scripts takes over 10 minutes to process, and due to various reasons, prints out nothing during this time.
Apache appears to have a timeframe of 10 minutes (600 seconds) for CGI scripts to run - and if no output appears from the script in this timeframe then the script is killed and a 500 response is sent to the browser/client.
The message:
[Thu Apr 23 13:57:53 2009] [warn] [client 127.0.0.1] Timeout waiting for output from CGI script /opt/jarvis/cgi-bin/jarvis.pl
appears in the log on one system (Ubuntu, installed via apt-get), but doesn't on another (Windows, installed via package download).
My question is - is there any configuration in Apache 2.2 that would allow me to run a script longer than 10 minutes without it being killed?
Edit
Writing log messages out regularly avoids this error - so a log message written every few minutes ensures that long running processes don't get killed. I eventually solved my problem by implementing a progress bar on the client and having my script write a "." every so often to update the bar on the other end.
Thanks, Jamie
Solution 1:
The TimeOut directive defines the length of time Apache will wait for I/O in various circumstances:
- When reading data from the client, the length of time to wait for a TCP packet to arrive if the read buffer is empty.
- When writing data to the client, the length of time to wait for an acknowledgement of a packet if the send buffer is full.
- In mod_cgi, the length of time to wait for output from a CGI script.
- In mod_ext_filter, the length of time to wait for output from a filtering process.
- In mod_proxy, the default timeout value if ProxyTimeout is not configured.
Solution 2:
As shown on http://cweiske.de/tagebuch/Running%20Apache%20with%20a%20dozen%20PHP%20versions.htm :
FastCgiServer /var/www/cgi-bin/php-cgi-5.3.1 -idle-timeout 120
The idle timeout sets the time in seconds that apache waits for the cgi to return something