duanjianao0592 2017-03-13 23:47
浏览 43
已采纳

检测作业何时完成并重新运行

I have put my web scraping function into a job and I want to run it continuously. I want to detect when the job is completed, and re-run the job. I created a command for triggering it once.

php artisan update:catalog works. In my command, inside handle, I placed dispatch the job

public function handle()
{
    dispatch(new \App\Jobs\UpdateCatalog());
}

And my job looks like this:

public function handle()
{
    doTheScraping();
}

Now, if I watch through php artisan queue:listen database and run the update:catalog command, it works for once.

How can I detect when the job is completed and re-run the job in completion?

  • 写回答

1条回答 默认 最新

  • dswfyq6201 2017-03-13 23:56
    关注

    You can dispatch the job recursively:

    public function handle()
    {
        doTheScraping();
        if (!$exit_condition) {
            dispatch(new self)
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码