Laravel 调度程序未自动运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31993033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel scheduler is not running automatically
提问by Wolfgang Müller
I have made a scheduler. When I call it with php artisan userRanking
it works.
我做了一个调度程序。当我用php artisan userRanking
它来调用它时。
This is the code in Kernel.php
:
这是中的代码Kernel.php
:
protected $commands = [
\App\Console\Commands\UserRanking::class,
];
protected function schedule(Schedule $schedule)
{
$schedule->command('userRanking')
->everyMinute();
}
How do I dispatch it so that it runs automatically?
我如何调度它以便它自动运行?
回答by Joseph Silber
You have to set up a single cron
job that calls the schedule runner every minute:
您必须设置一个cron
每分钟调用调度运行器的作业:
* * * * * php /path/to/artisan schedule:run 1>> /dev/null 2>&1
Read Laravel's Scheduler docsfor more info.
阅读Laravel 的调度器文档以获取更多信息。