php in background exec() function

前端 未结 1 1536
灰色年华
灰色年华 2020-11-30 15:13

I made this script to test the execution of PHP as a background process

foreach($tests as $test) { 
   exec(\"php test.php \".$test[\"id\"]); 
} 


        
相关标签:
1条回答
  • 2020-11-30 15:59

    exec() will block until the process you're exec'ing has completed - in otherwords, you're basically running your 'test.php' as a subroutine. At bare minimum you need to add a & to the command line arguments, which would put that exec()'d process into the background:

    exec("php test.php {$test['id']} &");
    
    0 讨论(0)
提交回复
热议问题