【发布时间】:2015-09-15 12:07:10
【问题描述】:
我在 CMD 中这样做:
php -f index.php
我想在 CMD 中不断运行这段代码,即使发生错误,
如何强制运行此命令?
【问题讨论】:
标签: php command-line cmd window command-prompt
我在 CMD 中这样做:
php -f index.php
我想在 CMD 中不断运行这段代码,即使发生错误,
如何强制运行此命令?
【问题讨论】:
标签: php command-line cmd window command-prompt
使用这个。
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.
【讨论】:
如果您想重新运行应用程序而不管它是否崩溃或被故意中断,像这样简单的事情就可以做到:
@echo off
:endless
php -f index.php
goto endless
将其放入foo.cmd,然后运行foo
【讨论】:
如果您使用的是 Linux 服务器,则可以使用以下方法:
#!/bin/bash
while :
do
php index.php
done
你通过运行sh ./test.sh来执行
对于窗户;以下作为 .bat 文件也可以使用
@echo off
cls
:start
php index.php
goto start
【讨论】: