doubiao1734 2019-05-04 00:45
浏览 42
已采纳

如何从给定时间开始laravel的调度程序?

I need to run certain commands after 2 days of another time that I read from database in laravel. I checked out the laravel's scheduler documentation but could not find anything related my problem.

How can I set up a scheduler relative to another time? I want to read a time/date from database and schedule a command based on this time. Also, It is not repetitive. It will only run once.

  • 写回答

1条回答 默认 最新

  • dongtuo5262 2019-05-04 01:05
    关注

    I think the best you can do is to setup a queued job. When you need to dispatch it (whenever it is in a scheduled task or not, it doesn't matter), you just dispatch it with a delay. It is well explained in the queue section of the documentation, right here: https://laravel.com/docs/5.7/queues#delayed-dispatching

    In your case, you can dispatch the job using this Carbon instance as a delay: now()->addDays(2). Two days later, the job will be executed :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 有人帮看看这个问题的嘛
  • ¥15 STM32悬赏求解答,ai不要来解答
  • ¥15 Mysql 一张表同时多人查询和插入怎么防止死锁
  • ¥20 centos6.7 安装libevent库.总是报错,如何解决?
  • ¥15 电脑买回,学校的有线网络总掉。
  • ¥20 关于普洛菲斯触摸屏与AB连接地址问题
  • ¥15 syri可视化不显示插入缺失
  • ¥30 运行软件卡死查看系统日志分析不出来
  • ¥15 C语言代码改正特征选择算法设计,贝叶斯决策,,设计分类器,远程操作代码修正一下
  • ¥15 String 类valuve指向的问题
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部