Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like Apache to terminate my perl script after 1 minute if it doesn't complete naturally. Is there a setting in Apache (or other server software) to do this?

share|improve this question

CGIwrap does much of the stuff that suEXEC does (run the script under alternate permissions), but it also allows you to set resource limits:

    limit cpu time with setrlimit
    limit total virtual memory with setrlimit
    limit total available memory with setrlimit
    limit writable file size with setrlimit
    limit data segment size with setrlimit
    limit stack segment size with setrlimit
    limit core file size with setrlimit
    limit resident set size with setrlimit
    limit number of processes with setrlimit
    limit number of open files with setrlimit
    limit lockable memory with setrlimit
share|improve this answer

Of the top of my head I can see two solutions (NOTE: I am a UNIX/Linux guy):

  1. Make modifications to your perl code to set an alarm and then program a signal processor to capture the alarm and perform whatever processing you want.

  2. You could manipulate the CPU limit of a process to terminate if it gets to 1 second CPU time. However, that real clock time length to get to 1 second of CPU time depends on your perl script.

share|improve this answer

You could always put "alarm 60;" at the top of your Perl scripts. However, this would require modifying all your Perl programs.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.