Laravel 5.1 Task Scheduling command issue

2019-07-17 18:10发布

问题:

I am trying to execute two console commands.Below is my two commands in my Kernel.php

protected function schedule(Schedule $schedule)
{
    $schedule->command('users:get')->everyMinute();

    $schedule->command('users:update')->dailyAt('01:00');
}

When I run php artisan schedule:run, Only the command which is/are scheduled as everyMinute is scheduled.

Running scheduled command: '/usr/bin/php5' 'artisan' users:get > /dev/null 2>&1 &

If I change the dailyAt to everyMinute for the second command, both are scheduled as shown below

Running scheduled command: '/usr/bin/php5' 'artisan' users:get > /dev/null 2>&1 &

Running scheduled command: '/usr/bin/php5' 'artisan' users:update > /dev/null 2>&1 &

回答1:

php artisan schedule:run will run the scheduled commands, not list them.

So, if you run the scheduled commands before 01:00 the users:update command will not be scheduled yet and will not be ran.