【问题标题】:loop php script in bash在bash中循环php脚本
【发布时间】:2016-08-19 18:58:28
【问题描述】:

我需要在 linux bash 中每秒运行一次 php cli。 您可以在下面找到我的 windows.bat 文件:

:loop
start /b pathTophp.exe pathTo\cycler.php
timeout /t 1
goto loop   

也许我可以使用 cron 并每秒运行一次这个简单的脚本,但我认为分钟是最小的间隔。

#!/bin/bash php56 cycler.php

据我所知,bash 中没有 goto,而且我根本不了解 bash。那我该怎么做呢?

【问题讨论】:

    标签: php linux bash cron


    【解决方案1】:

    你是正确的 cron 只能去 1 分钟的间隔,试试这个

    #!/bin/bash
    while true
    do 
     php56 cycler.php
     sleep 1
    done
    

    这将循环直到你用 ctrl-c 停止它

    【讨论】:

    • 谢谢,它可以工作,并且对于这个唯一的测试项目来说已经足够了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多