$update_num = 1000;
$limit = 100;
$p_num = 0;
$line_cmd = 'ps -ef grep doit.php grep -v grep wc -l';
$exec_cmd = '/usr/local/php/bin/php doit.php %s & > /dev/null 2>&1';
$t1 = microtime(1);
for($i = 0 ; $i < $update_num ; $i++){
if($p_num < =0){
$fp1 = Popen($line_cmd,'r');
//現在のシェルプロセス番号
$line = fread($fp1,512);
pclose($fp1 );
//プロセスはプッシュ可能
$p_num = $limit - $line;
if($p_num <= 0 ){
usleep(100);
}
}
$p_num = $p_num -1;
$cmd = sprintf($exec_cmd,$i);
$fp = Popen($cmd,'r');
pclose($ fp);
}
$t2 = microtime(1);
echoround($t2 - $t1,2);
?>
スリープ(2);
$fp = fopen('doit.txt','a');
fwrite($fp,$argv[1]."n");
fclose($fp) ;
終了(0);
?>
本文http://www.cxybl.com/html/wlbc/Php/20120531/27133.html