JohnDotOwl
JohnDotOwl

Reputation: 3755

Issue with Laravel schedule task

Kernel file

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');
    }
}

Console Command File 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

I tried to reboot clear this clear that cache config , still the same, i went to laravel docs , checked their docs, its the same, watch video also same? ....this is laravel 5.5

I need this php artisan schedule:run because i have to get laravel to call this every minute.

When i run php artisan command:SendDownNotification

It works totally fine .....

Upvotes: 1

Views: 834

Answers (1)

jedrzej.kurylo
jedrzej.kurylo

Reputation: 40909

You need to pass the full command name when you want to schedule it. That's also what the error message is telling you - it can't find the command with given name, but instead suggests the one with full name.

Replace

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

with

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

Upvotes: 2

Related Questions