1

I have five exec() function in my script, which run one after another. I want exec() function stops its execution after 10 sec and next exec() function starts its execution.

<?php
  exec("/usr/local/bin/wrun 'uptime;ps -elf|grep httpd|wc -l;free -m;mpstat'",$uptime);
  foreach($uptime as $load){
    echo $load."<br />";
  }

  exec("/usr/local/bin/trun 'uptime;ps -elf|grep httpd|wc -l;free -m;mpstat'",$uptime);
  foreach($uptime as $load){
    echo $load."<br />";
  }

  exec("/usr/local/bin/drun 'uptime;ps -elf|grep httpd|wc -l;free -m;mpstat'",$uptime);
  foreach($uptime as $load){
    echo $load."<br />";
  }

   .......
  ?>
gturri
  • 13,807
  • 9
  • 40
  • 57
Tomas
  • 514
  • 4
  • 13
  • 37

1 Answers1

0

set_time_limit() does run globally, but you may be able to set it locally,

<?php
set_time_limit(0); 
function do()
{
    set_time_limit(10);   
    //  work
    set_time_limit(10);   

}

// ....
sleep(900);
// ....
do();  // only has 10 secs to run
// ....
sleep(900);
Smoke
  • 89
  • 1
  • 8
  • 15