-
-
#!/usr/bin/env php
-
/**
- * php 多进程
- * by bbs.it-home.org
- */
- $cmds=array(
- array('/app/test.php','charge/pstat.php','mobile',1),
- array('/app/test.php','charge/pstat.php','mobile',2),
- array('/app/test.php','charge/pstat.php','click',1),
- array('/app/test.php','charge/pstat.php','click',2),
- array('/app/test.php','charge/pstat.php',1),
- array('/app/test.php','charge/pstat.php',2)
- );
foreach($cmds as $cmd){
- $pid=pcntl_fork();
- if($pid==-1){ //进程创建失败
- die('fork child process failure!');
- }
- else if($pid){ //父进程处理逻辑
- pcntl_wait($status,WNOHANG);
- }
- else{ //子进程处理逻辑
- pcntl_exec('/usr/local/bin/php',$cmd);
- }
- }
- ?>
-
复制代码
|