dongmin3754 2014-09-05 23:49
浏览 68
已采纳

如何在Laravel 4中获得“cron”支持?

Does self-hosted (non-Forge) Laravel have a cron system? Or has this been supplanted by worker queues?

That is, in many PHP frameworks, there's a single cron file to run -- often named cron.php. You're usually instructed to configure this script to run every 15 minutes (or some similar time) via a unix cron job.

1,15,30,45 * * * * /path/to/php /path/to/cron.php

Does Laravel have a similar system? Googling about I've seen some mentions that Forge has a solution for this, and that older version of Laravel might have had a system, but I haven't been able to find a clear answer W/R/T Laravel 4.

  • 写回答

1条回答 默认 最新

  • dscizpq790832708 2014-09-06 00:14
    关注

    You can schedule artisan commands and make your own commands like so:

    php artisan command:make cronCommand
    

    Which will result in a cronCommand.php file in your app/commands directory

    Then you make artisan aware of the command

    Add Artisan::add(new cronCommand); to app/start/artisan.php

    composer dump-autoload
    

    Now you can see your new command via php artisan list

    and schedule it via 1,15,30,45 * * * * artisan cronCommand


    Reference

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

报告相同问题?

悬赏问题

  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?