Laravel 5.1命令和作业 [英] Laravel 5.1 commands and jobs

查看:66
本文介绍了Laravel 5.1命令和作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,命令现在是Laravel 5.1中的工作.如果要调度作业,那么是否应该从命令中调用作业(因为调度程序只能调用命令而不能调用作业)?

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)?

在Laravel 5.1的虚拟设置中,仍然存在一个带有Inspire.php的app/Console/Commands文件夹.从调度程序中调用激励命令.因此,如果我想安排一个作业,我应该先调用一个命令,然后再在此命令中调用该作业吗?

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?

推荐答案

命令不是作业.命令是命令-您可以创建命令并通过命令行使用它们.但是,它们可以用于安排重复的任务.

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:

您需要添加到服务器的唯一Cron条目是:

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

          • php/path/to/artisan schedule:run 1 >>/dev/null 2>& 1
                  • 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?

                  这篇关于Laravel 5.1命令和作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆