Php Laravel计划程序未运行命令
我在app/Console/中的Kernel.php中安排了这些命令Php Laravel计划程序未运行命令,php,laravel,laravel-5,scheduled-tasks,laravel-5.7,Php,Laravel,Laravel 5,Scheduled Tasks,Laravel 5.7,我在app/Console/中的Kernel.php中安排了这些命令 protected function schedule(Schedule $schedule) { $schedule->command('inspire')->everyMinute(); $schedule->command("trustpilot:send")->everyMinute(); $schedule->command("run:status")->e
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')->everyMinute();
$schedule->command("trustpilot:send")->everyMinute();
$schedule->command("run:status")->everyFiveMinutes();
}
当我运行php artisan schedule:run时,我收到以下消息:
没有计划的命令可以运行
这很奇怪,因为如果我正在转储$schedule->dueEvents($this->app)我会得到一个包含事件inspire和trustpilot:send的列表
我试图在/vendor/laravel/framework/src/illighted/Console/Scheduling/ScheduleRunCommand.php中转储dueEvents列表,但这里的列表是空的
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
dd($this->schedule->dueEvents($this->laravel)); <---- EMPTY?
foreach ($this->schedule->dueEvents($this->laravel) as $event) {
if (! $event->filtersPass($this->laravel)) {
continue;
}
.....
/**
*执行控制台命令。
*
*@返回无效
*/
公共函数句柄()
{
dd($this->schedule->dueEvents($this->laravel));schedule->dueEvents($this->laravel)作为$event){
如果(!$event->filtersPass($this->laravel)){
继续;
}
.....
以前有人经历过吗?我明白了
在应用程序的启动命令中,我运行了以下命令:
Artisan::call('....');
它覆盖旧的schedueler实例,这就是dueEvent列表为空的原因
我删除了该行,然后开始工作:)“当我运行php artisan schedule:run时,我会收到以下消息:…”-答案是不要手动运行php artisan schedule:run。将其放入
CRON
脚本中。请阅读计划文档::“使用计划程序时,您只需要将以下CRON条目添加到服务器。”@TimLewis仍然,应该在手动调度:run
调用中选择everyMinute
命令。@ceejayoz仅当您在everyMinute()的精确秒数运行它时
调用对应于。@timliews…这不是Laravel调度的工作方式。它不关心秒数。不需要道歉:)我以前没有见过这个用例;关于这个问题还有很多其他问题(“没有调度命令…”),但大多数都没有everyMinute()
,所以当他们手动运行它时,它实际上不是正确的时间(例如everyFiveMinutes()
)。很高兴你让它工作了!