Search code examples
apacheperltimeoutcgi

Apache timeout in perl CGI tool


I am running a Perl CGI tool that executes a system command (Unix) which may run for a few seconds up to an hour. After the script is finished, the tool should display the results log on the screen (in a browser). The problem is that after about 5 minutes I get a timeout message "Gateway Time-out" - the system command continue to run but I'm unable to display to the user the results of the run.

In the Apache config file (httpd.conf): Timeout 300.

Is there a simple way ordering the Apache to increase the timeout only for a specific run? I don't really want to change the Apache timeout permanently (or should I?) and not dramatically update the code (a lot of regression tests).


Solution

  • Make the script generate some output every once in a while. The timeout is not for running the program to completion, but is a timeout while Apache is waiting for data. So if you manage to get your program to output something regularly while running, you will be fine.

    Note that HTTP clients, i.e. browsers, also have their own timeout. If your browser does not get any new data from the web server five minutes (typically), the browser will declare a timeout and give up even if the server is still processing. If your long running processing gives some output every now and then, it will help against browser timeouts too!