Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

migrated from stackoverflow.com Jun 6 '11 at 11:37

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

The TimeOut directive defines the length of time Apache will wait for I/O in various circumstances:

  1. When reading data from the client, the length of time to wait for a TCP packet to arrive if the read buffer is empty.
  2. When writing data to the client, the length of time to wait for an acknowledgement of a packet if the send buffer is full.
  3. In mod_cgi, the length of time to wait for output from a CGI script.
  4. In mod_ext_filter, the length of time to wait for output from a filtering process.
  5. In mod_proxy, the default timeout value if ProxyTimeout is not configured.
share|improve this answer
    
I'd agree, except I have: Timeout 300 In my apache.conf file, and it doesn't limit to 5 minutes. –  Jamie Love Apr 23 '09 at 2:51
    
How does Apache kill the child CGI script? I need to catch that, but can't find any docs on whether it's possible for the child to cleanly shutdown when it's killed by Apache. –  Alnitak Jan 10 '11 at 12:19
    
@JamieLove: A scant 3+ years later.. I ran into the same thing. The problem was that even though I didn't specify it, apache was using mod_cgid, not mod_cgi.. mod_cgid in 2.2.x doesn't seem to honor the timeout. While I suspect that you've probably resolved your problem by this point.. I leave this feedback for the next guy who has this same issue. :p –  synthesizer Feb 23 '12 at 19:37
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.