【问题标题】:how can I run php from command line constantly如何不断地从命令行运行 php
【发布时间】:2015-09-15 12:07:10
【问题描述】:

我在 CMD 中这样做:

php -f index.php 我想在 CMD 中不断运行这段代码,即使发生错误, 如何强制运行此命令?

【问题讨论】:

    标签: php command-line cmd window command-prompt


    【解决方案1】:

    使用这个。

    ignore_user_abort(1); // Set whether a client disconnect should abort    script execution
    set_time_limit(0); //Limits the maximum execution time, in this case it runs until the process finishes or apache restart.
    

    【讨论】:

      【解决方案2】:

      如果您想重新运行应用程序而不管它是否崩溃或被故意中断,像这样简单的事情就可以做到:

      @echo off
      :endless
      php -f index.php
      goto endless
      

      将其放入foo.cmd,然后运行foo

      【讨论】:

        【解决方案3】:

        如果您使用的是 Linux 服务器,则可以使用以下方法:

        #!/bin/bash
        while :
        do
           php index.php
        done
        

        你通过运行sh ./test.sh来执行

        对于窗户;以下作为 .bat 文件也可以使用

        @echo off
        cls
        :start
          php index.php
        goto start
        

        【讨论】:

          猜你喜欢
          • 2016-12-15
          • 2021-06-20
          • 2016-07-21
          • 2011-08-04
          • 2013-12-28
          • 1970-01-01
          • 2015-11-11
          • 1970-01-01
          • 2014-06-01
          相关资源
          最近更新 更多