0

I'm trying to get the Laravel Scheduler to run a couple of commands, however when I run php artisan schedule:run it will only run one of the commands in the kernal.php file.

My Kernal.php file is as follows:

protected $commands = [
];

/**
 * Define the application's command schedule.
 *
 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{
    $schedule->command('a:import')->everyMinute();
    $schedule->command('b:import')->everyFiveMinutes();
}

/**
 * Register the Closure based commands for the application.
 *
 * @return void
 */
protected function commands()
{
    require base_path('routes/console.php');
}

My console.php file has the following code:

Artisan::command('a:import', function(a\ImportController $runner) {
    $runner->init();
});

Artisan::command('b:import', function(b\ImportController 
$runner) {
    $runner->beginImport();
});

and when I run php artisan schedule:run I get the following result:

D:\development\v2> php artisan schedule:run

 ´╗┐Running scheduled command: "C:\Program Files\PHP\v7.0\php.exe" "artisan" a:import > "NUL" 2>&1

Any help in identifying what I've missed or anything else I need to do would be appreciated.

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
SL Luke
  • 1
  • 2

4 Answers4

0

The output might be a bit misleading but actually is valid. You set a:import to be running every minute and b:importto run every 5 minutes so when you run:

php artisan schedule:run

you will see that a:import command was run 5 times often than b:import

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
0

Have you setup a cron, of course it wont run...

Gumehara
  • 78
  • 5
0

Did you add the schedule command in the crontab?

0

You have to register your custom commands inside the $commands array:

protected $commands = [
    Commands\A::class,
    Commands\B::class
];
Fred Vanelli
  • 662
  • 8
  • 9