I have a list of jobs in my database, when I run php artisan queue:work database
, it processes each job but once it processes the last one, it doesn't seem to stop. I thought doing it this way would mean once the worker has no jobs left, it stops.
Add the --once
option if you want the worker to exit after running one job:
$ php artisan queue:work --once
As of 5.7 you can use --stop-when-empty
to process all jobs in the queue and then exit:
$ php artisan queue:work --stop-when-empty
Docs: https://laravel.com/docs/5.7/queues#running-the-queue-worker
Note: The default behavior changed around Laravel 5.3. Previously a worker would process one job and exit; it only continued running if the --daemon
option had been used. After 5.3 this became the default behavior, and --daemon
was deprecated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With