Laravel 计划任务问题

Issue with Laravel schedule task

内核文件

namespace App\Console;
use DB;
use Log;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{

    protected $commands = [
          \App\Console\Commands\SendDownNotification::class,
    ];

    protected function schedule(Schedule $schedule)
    {
      $schedule->call(function () {
          Log::info('test');
      })->everyMinute();

      $schedule->command('SendDownNotification')->everyMinute();
    }

    protected function commands()
    {
        $this->load(__DIR__.'/Commands');
        require base_path('routes/console.php');
    }
}

控制台命令文件SendDownNotification.php

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Log;

class SendDownNotification extends Command
{
    protected $signature = 'command:SendDownNotification';

    protected $description = 'Notify if it went offline';


    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        Log::info('HIT Command');
    }
}

php artisan schedule:run

我试过重启清除缓存配置,还是一样,我去laravel文档,查了他们的文档,一样,看视频也一样? ....这是laravel 5.5

我需要这个 php artisan schedule:run 因为我必须让 laravel 每分钟调用一次。

当我运行phpartisancommand:SendDownNotification

完全没问题.....

当你想安排它时,你需要传递完整的命令名称。这也是错误消息告诉您的内容 - 它找不到具有给定名称的命令,而是建议具有全名的命令。

替换

$schedule->command('SendDownNotification')->everyMinute();

$schedule->command('command:SendDownNotification')->everyMinute();