Super User is a question and answer site for computer enthusiasts and power users. 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 have five exec() functions in my script. I want to set it up so that if a function fails to respond in a given time, the function will be killed and the next function will start its execution.

    exec("timeout 5 /usr/local/bin/wrun 'uptime;ps -elf|grep httpd|wc -l;free -m;mpstat'",$uptime);  
    exec("timeout 5 /usr/local/bin/trun 'uptime;ps -elf|grep httpd|wc -l;free -m;mpstat'",$uptime);  
    exec("timeout 5 /usr/local/bin/drun 'uptime;ps -elf|grep httpd|wc -l;free -m;mpstat'",$uptime);

In this the timeout argument is not working. Please correct this or give me an alternative method.

share|improve this question

your exec sysntax is wrong

string exec ( string $command [, array &$output [, int &$return_var ]] )

You have to set time limit before you begin your code, something like this



exec(" /usr/local/bin/wrun 'uptime;ps -elf|grep httpd|wc -l;free -m;mpstat'",$uptime);
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.