dongzhao4036 2012-03-27 01:54
浏览 304
已采纳

如何在Mac中同时执行PHP CLI脚本

I have 50 php files that I would like to run simultaneously from the command line. Right now, I am running them in multiple CLI windows using the code:

php Script1.php

I would like to be able to call one single script file that would execute all 50 php files simultaneously. I have been reading about how to make the command line not wait for the output, but I can't seem to make it work.

I am new to both MAC and Scripting - maybe I don't need a script? Is there another mac based solultion that can do this without me having to open 50 separate terminal windows?

  • 写回答

3条回答 默认 最新

  • duanshanduo3363 2012-03-27 02:00
    关注

    You can just add ampersand '&' to separate each command:

    php script1.php & php script2.php & php script3.php ...
    

    This ampersand symbol will tell the shell to run command on background.

    To check the output, you can redirect it to a file:

    php script1.php > script1.log.txt & php script2.php > script2.log.txt
    

    And you can just do a tail on it to read the log:

    tail -f script1.log.txt
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?