In my table "jobs" have 5 jobs, i used the process "php artisan queue:listen" on localhost then it ran all jobs and finished. But when i used this process on server then it only once ran one jobs (same "php artisan queue:work"). I use queue_driver is "database".
2 Answers
TL;DR
php artisan queue:work
= run one queued job and stop
php artisan queue:listen
= run all queued jobs and listen for more until stopped
Further detail:
How are you running the commands? Are you just opening a terminal and running it or do you have a cron job to run at intervals?
If you're just opening a terminal and running php artisan queue:work
will complete one task on the queue then stop, whereas if you run php artisan queue:listen
it will process all the jobs in the queue and continue to listen for any further jobs until it is stopped.
Read further in the docs regarding queue:work
:
Starting The Queue Listener
Laravel includes an Artisan command that will run new jobs as they are pushed onto the queue. You may run the listener using the queue:listen command:
php artisan queue:listen
Processing The First Job On The Queue
To process only the first job on the queue, you may use the queue:work command:
php artisan queue:work
What you should be doing?
I am guessing what you ideally want to do on your server is set up a cron job to run continuously at intervals and have it run queue:work
. Better yet, acquaint yourself with the docs and make a decision after that.
See similar question answered here: What is the difference between queue:work --daemon and queue:listen
-
1Hi @haakym, I used the command "php artisan queue:work --daemon" and succeed, this command run all jobs in my queue. Thank you very much. – dungdoan May 16 '16 at 04:08
-
@dungdq You're welcome, glad you got it working! If the answer I gave solved your question you can mark it as correct by pressing on the tick next to my answer or if it is was helpful you can upvote it. Thanks. – haakym May 16 '16 at 07:48
-
Xampp : `php artisan queue:listen` not listens upcoming jobs. just runs already added and stops. – 151291 Dec 15 '17 at 12:49
-
Docs say otherwise: https://laravel.com/docs/5.5/queues#running-the-queue-worker you're best making your own question and explaining the whole process you're attempting and what happens and what you are expecting to happen – haakym Dec 15 '17 at 15:19
-
`queue:listen` are just processing one queue item but I have 20 queue items in the database and more getting stacked. To clear up queue items I need to run `queue:listen` again and again, each time clearing just one. @haakym – Ankit Jindal Sep 03 '20 at 06:45
-
from Laravel docs > Note that once the queue:work command has started, it will continue to run until it is manually stopped or you close your terminal – shamaseen Oct 22 '21 at 17:22