$count = $this->objBlbServer->getCntByConds(['id >0']); //开启四个进程 $pageCount = 4; $pageSize = ceil($count / $pageCount); for ($i = 1; $i <= $pageCount; $i++) { $pid = pcntl_fork(); if ($pid == -1) { //进程创建失败 die('fork child process failure!'); } elseif ($pid) { //父进程处理逻辑 pcntl_wait($status, WNOHANG); } else { //子进程处理逻辑 pcntl_exec('/home/homework/php/bin/php', [ '/home/homework/app/noah/script/cron/BlbBackendServer.php', $i, $pageSize ]); } }