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

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

报告相同问题?

悬赏问题

  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan