Hese
Hese

Reputation: 290

Laravel cronjob schedule command not firing on production

I have 7 different schedule commands on kernel.php and one of those is not firing when running the schedule.

kernel.php
....
$schedule->command('my:command')->hourlyAt(15); // this wont run
...

Running php artisan my:command manually on command line works fine.

Also when running the scheduler on our dev server, all commands works fine. The problem is only on production server.

There are no errors on log files.

Any ideas what might be wrong?

I'm using Laravel 5.6


UPDATED: The problem was wrong artisan path on laravel forge scheduler

Upvotes: 0

Views: 2185

Answers (2)

Jan Pedryc
Jan Pedryc

Reputation: 409

Check timezone configs of your server and scheduled tasks as well. I haven't set the time zones on the tasks, and by default it was set to UTC. You can verify when the jobs should run by:

php /path/to/project/artisan schedule:list

  40 22 * * *  App\Jobs\SomeJob ...... Next Due: 6 minutes from now
  40 6  * * *  App\Jobs\SomeJob ........ Next Due: 8 hours from now
  40 14 * * *  App\Jobs\SomeJob ....... Next Due: 16 hours from now

Upvotes: 0

Vipul Prajapati
Vipul Prajapati

Reputation: 223

Have you add following cron entry as per your project folder path ?

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

please check with following commands

crontab -l

If not ?

open crontab by

crontab -e

add * * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1 entry at the end of file

save file and run following commands

sudo service cron restart

again check with crontab -l

this command will return already set cronjob

i hope it helps :)

Upvotes: 2

Related Questions