简体   繁体   中英

How to run queue:work command in laravel task scheduler?

I have been searching a lot for a solution until I just gave up... I want to run php artisan queue:work --stop-when-empty command every minute in Laravel task scheduler.

I have tried this

$schedule->command('queue:work --stop-when-empty')->everyMinute()->runInBackground();

but that doesn't seem to work at all...

You are not supposed to run the queue in the scheduler.

The queue should always be up and running (using a process manager, like Supervisor) and pick jobs when they are dispatched (dispatched in a scheduled task or somewhere else, it doesn't matter).

Here is the documentation on this topic: https://laravel.com/docs/8.x/queues#supervisor-configuration

Can you explain why the schedule approach does not work?

I have a situation here, that I can't use the Supervisor. And I had thought of doing it something like this:

$schedule->command('queue:work')->everyFiveMinutes()->withoutOverlapping()->runInBackground();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM