0

I have setup a command to run every Saturday at midnight but it is not working I write this but not running

$schedule->command('weeklyRewardPoints')->weeklyOn(6, '00:00')->timezone('Asia/Dubai');

then I try this but again not working

$schedule->command('weeklyRewardPoints')->weeklyOn(6, '0:0')->timezone('Asia/Dubai');

Even I tried to run at any specific minute at midnight like this but still not working

$schedule->command('weeklyRewardPoints')->weeklyOn(6, '00:30')->timezone('Asia/Dubai');

It is working successfully any other hour and minutes but not at midnight hour and minutes

this is my cron job

* * * * 6     php /home/path-to-my-project/artisan schedule:run >> /dev/null 2>&1
codedge
  • 4,754
  • 2
  • 22
  • 38
habib
  • 89
  • 1
  • 10

1 Answers1

1

Taken from the Laravel docs

So, when using Laravel's scheduler, we only need to add a single cron configuration entry to our server that runs the schedule:run command every minute.

the scheduler need cronjob needs to run every minute

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

your scheduler runs every 6 minutes.

You can furthermore write

$schedule->command('weeklyRewardPoints')->weeklyOn(6)->timezone('Asia/Dubai');

and remove the time from weeklyOn as it is predefined with 0:0.

codedge
  • 4,754
  • 2
  • 22
  • 38
  • 1
    thank you for telling me this. I did not know that we have to run cron every minute on server – habib Feb 02 '21 at 20:18