由于php的进程是不支持多线程的,有些场景为了方便以及提高性能,可以用php实现多进程以弥补这个不足:
#!/usr/bin/env php<BR><?php<BR>$cmds=array(<BR> array('/apps/bin/launcher.php','charge/promotion_props_stat.php','mobile',1),<BR> array('/apps/bin/launcher.php','charge/promotion_props_stat.php','mobile',2),<BR> array('/apps/bin/launcher.php','charge/promotion_props_stat.php','click',1),<BR> array('/apps/bin/launcher.php','charge/promotion_props_stat.php','click',2),<BR> array('/apps/bin/launcher.php','charge/promotion_props_stat.php',1),<BR> array('/apps/bin/launcher.php','charge/promotion_props_stat.php',2)<BR>);</P><P>foreach($cmds as $cmd){<BR> $pid=pcntl_fork();<BR> if($pid==-1){ //进程创建失败<BR> die('fork child process failure!');<BR> }<BR> else if($pid){ //父进程处理逻辑<BR> pcntl_wait($status,WNOHANG);<BR> }<BR> else{ //子进程处理逻辑<BR> <span>%本文来源gaodai#ma#com搞*代#码9网#</span><strong>搞gaodaima代码</strong> pcntl_exec('/usr/local/bin/php',$cmd);<BR> }<BR>}<BR>