Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AyCodeur's avatar

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

0 likes
1 reply
AyCodeur's avatar

I found the solution, i had to use the --force in the migrate command. And by the way i have another question, i have to do some tests to my database every x time, so what's the best way to do it? create a controller and do the call from the schedule or do the test in commands folder ?

Please or to participate in this conversation.