RASEL RANA
RASEL RANA

Reputation: 2190

Laravel command setup into digitalocean cron job but not working

In my laravel application under routes/console.php have one command. I want to run this command every minute which is given below:

Artisan::command('inspire', function () {
   $this->comment(Inspiring::quote());
})->describe('Display an inspiring quote');

In digital ocean crontab i registered below command but not working.

 * * * * * cd /var/www/html/laravel_projects/user_profile/ && php artisan schedule:run 1>> /dev/null 2>&1

N.B: In digitalocean cron status showing it's active and if i run this command under project directory manually & its' working.

Upvotes: 1

Views: 743

Answers (3)

Mayur Sojitra
Mayur Sojitra

Reputation: 712

sudo service cron restart

execute this command to restart cronjob service

Upvotes: 0

Vipul Prajapati
Vipul Prajapati

Reputation: 223

Add task schedule inside App\Console\Kernel.php

protected function schedule(Schedule $schedule)
{
    $schedule->command('reminders:send')->everyMinute();
}

I hope it helps.

Upvotes: 0

Peter
Peter

Reputation: 1725

You need to define a schedule to tell Laravel which commands you want to run.

Your task schedule is defined in the app/Console/Kernel.php file's schedule method.

protected function schedule(Schedule $schedule)
{
    $schedule->command('inspire')->daily(); // or some other time
}

https://laravel.com/docs/5.8/scheduling#defining-schedules

Upvotes: 1

Related Questions