1

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.

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks actually, This is my action 1. run 'crontab -e' 2. Insert '* * * * * php /var/www/html/srp && php artisan schedule:run >> /dev/null 2>&1' and save. Then bang, work great.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.