我的脚本中有五个exec()
函数,它们一个接一个地运行。我希望exec()
函数在10秒后停止执行,然后下一个exec()
函数开始执行。
<?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 />";
}
.......
?>
答案 0 :(得分:0)
set_time_limit()确实全局运行, 但你可以在本地设置它,
<?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);