Laravel 5.1 commands and jobs

北慕城南 提交于 2020-01-25 11:01:05

问题


So, as far as I understand, commands are now jobs in Laravel 5.1. If I'd like to schedule a job, should I call a job from a command then (since the scheduler can only call commands and not jobs)?

In the dummy setup of Laravel 5.1 there still is a app/Console/Commands folder with Inspire.php in it. The inspire command is called from the scheduler. So if I'd like to schedule a job, should I call a command and then call the job inside this command?


回答1:


Commands are not jobs. Commands are commands - you can create them and use them via command line. They can, however, be used for scheduling repeated tasks.

In this case - if you need a "job" - the documentation states:

The only Cron entry you need to add to your server is this:

          • php /path/to/artisan schedule:run 1>> /dev/null 2>&1

After you did that, you are free to use the implementation explained here. Basically, you use the Scheduler to set tasks that will run in whatever iterations you like. Pretty cool, isn't it?



来源:https://stackoverflow.com/questions/31995183/laravel-5-1-commands-and-jobs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!