Chaiwat Jo
Chaiwat Jo

Reputation: 143

Laravel schedule does not run automatically

I have laravel schedule setup as below

  1. Create command and name its.

    class BackupDatabase extends Command{
     protected $signature = 'command:backupdatabase';
    
  2. Register command in kernel.php

    protected $commands = [
    Commands\BackupDatabase::class
    
  3. Setup handle

    Artisan::call('backup:run',['--only-db'=>true]);
    $output = Artisan::output();
    
  4. Add to schedule

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

Nothing happen on this schedule. Btw, I already tried 'php artisan command:backupdatabase' in terminal and function working perfectly. I'm not sure what I'am doing wrong, Thanks for all advise.

Upvotes: 1

Views: 1714

Answers (1)

Daniele Sesoldi
Daniele Sesoldi

Reputation: 102

You have to set up the crontab

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

Laravel scheduled tasks work becouse the system is scheduled to execute the laravel command "schedule:run" that itself take care of executing the laravel scheduled command on the right time.

Upvotes: 2

Related Questions