Note: My question has nothing to do with Command schedule in Laravel which schedule not work. But in my question the scheduling works, but it cannot call the art
It costs me a day to google the issue, read laravel docs, and run many test. Finally I make it out.
Laravel's artisan queue:listen
command call the schedule()
in the Kernel.php periodically, while it only run the Log::info()
in the schedule()
not the $schedule->command()
(Here I'm also confused).
I've four queue running, for queue1 sudo -u www-data php artisan queue:work --queue=queue1 --env=worker_env --delay=3 --timeout=600
. Same with queue2, 3, 4. So the Log::info()
in the schedule()
will executed four times every 3 seconds.
Above make me thought the schedule works well. Actually, the schedule is not executed. I found /etc/cron.minutely/printer-task-minute
have no x
privilege, so I add the x
privilege for it. And I found I didn't config the crontab file, so I add * * * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.minutely )
to /etc/crontab
(I'm not familar with cron).
Solution:
Config the cron like above, or refer to the manual.
Change queue:listen
to queue:work
(When changed to queue:work
, schedule()
will not executed by queue periodically, I also don't know the reason here.).
I think you should be using the below command
$schedule->command('printer_serving')->everyMinute();