Gavroch
Gavroch

Reputation: 81

Php artisan schedule dosen't execute the command

so I'am trying to run a task with laravel schedule and php schedule:run works well but it does not execute the command in real

There is my kernel class

use Illuminate\Console\Scheduling\Schedule;
use Laravel\Lumen\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        //

    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        //$schedule->exec('php artisan migrate:fresh')->everyMinute();
        $schedule->command('migrate:fresh')->everyMinute();
    }
}

And the result of php schedule:run

Running scheduled command: '/usr/bin/php7.2' artisan migrate:fresh > '/dev/null' 2>&1

Upvotes: 1

Views: 628

Answers (1)

ColinMD
ColinMD

Reputation: 964

You need to create a CRON job to run scheduler every minute.

The CRON will then automatically fire every minute and run whatever command you set in the kernel->schedule function.

You can find the details in the Laravel documentation under Starting The Scheduler

Upvotes: 2

Related Questions