dongnei3634
2018-08-02 05:21
浏览 125
已采纳

每10秒运行一次PHP脚本作为cron作业

This question may seem repetitive, as there are many threads around with the same subject, but thing is that most solutions seems to be linked with terminal coding, which i'm not comfortable with. The problem is simple i have a php script that needs to be executed very 10 seconds. Cron job in cpanel allows only upto 1 minute. What's the workaround to let cron work every 10 seconds ?

图片转代码服务由CSDN问答提供 功能建议

这个问题可能看起来很重复,因为有许多相同主题的线程,但事实是大多数解决方案似乎 与终端编码相关联,我不满意。 问题很简单,我有一个需要执行10秒钟的PHP脚本。 cpanel中的Cron作业只允许最多1分钟。 让cron每10秒工作一次的解决方法是什么?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • dqsong2010 2018-08-02 05:35
    已采纳

    Let the cron job run after every minute and in your php script the following code example might help you out. I have used counter limit to 6 because this script will run after every ten seconds and six times in one minute.

    <?php
    for($i=0;$i<6;$i++){
        sleep(10);
        task();
    }
    
    function task(){
    
    }
    
    评论
    解决 无用
    打赏 举报
  • 查看更多回答(3条)

相关推荐 更多相似问题