I'm settin up my offline job server. I've read the documentation but I still don't really see the differences between the two commands: artisan queue:work --daemon
and artisan queue:listen
. Which command should I use for running my daemons?

- 7,039
- 7
- 36
- 44
4 Answers
Edit updated 2017-04-07:
There are now three ways to run your queue:
queue:work
- this is the new "daemon" process (the flag is no longer required). The framework will fire up "once" - and then keep looping through the jobs. This will continue indefinitely. It uses less memory/cpu thanqueue:listen
because the framework stays up the entire time. You must also remember to usequeue:restart
to force the queue to update any code changes you push during patching.queue:work --once
- this will fire up the framework, process one job, then shutdown. Useful for testing during development etc.queue:listen
- this will fire the framework up on every cycle, process one job, then fully shutdown, and then fire the framework up again etc and loop indefinitely. This means all memory/processes are released after each job is processed. If you have memory leaks withqueue:work
- give this a try.
The --daemon
flag no longer has an effect on these commands.
Original answer:
There are two different issues listed.
There is artisan queue:work
and artisan queue:listen
queue:work
will simply pop off the next job in the queue, and process only that one job. This is a 'one off' command that will return to the command prompt once the one queue command is processed.queue:listen
will listen to the queue, and continue to process any queue commands it receives. This will continue running indefinitely until you stop it.
In Laravel >=4.2 there was a --daemon
command added. The way it works is simply keeps running the queues directly, rather than rebooting the entire framework after every queue is processed. This is an optional command that significantly reduces the memory and cpu requirements of your queue.
The important point with the --daemon
command is that when you upgrade your application, you need to specifically restart your queue with queue:restart
, otherwise you could potentially get all sorts of strange errors as your queue would still have the old code in memory.
So to answer your question "Which command should I use for running my daemons?" - the answer is almost always queue:work --daemon

- 15,992
- 7
- 69
- 116

- 58,936
- 21
- 171
- 212
-
How can I run the daemon in background? Where should I put code to restart the queue? – Dev Apr 08 '15 at 07:03
-
2If you are running with the --daemon flag you need to take the memory warning in the docs seriously. If you are handling large files or doing other memory intensive stuff the process will likely leak at least some memory and will eventually crash. I've even tried releasing memory within these jobs with little success. Better to use Supervisor to spawn new Queue::work processes. – ShaunUK Sep 29 '15 at 15:16
-
1I still don't get what's the difference between queue:listen and queue:work --daemon. queue:listen runs indefinitely and queue:work --daemon also runs indefinitely without reloading the framework, so what's the difference? – Armen Markossyan Mar 09 '16 at 18:31
-
It seems like work and listen pretty much the same thing, with some differences under the hood. How can you process the queue and then exit without listening for more events? – Lucas Jun 12 '17 at 12:59
-
@Laurence this will only process one job, not all jobs in the queue. – Lucas Jun 17 '17 at 09:12
-
1@Lucas - yes, correct. You either process one job and exit, or you process indefinitely. There is no in between. – Laurence Jun 18 '17 at 19:27
-
Why would running a single job increase the amount of memory used? Once a job is done, the process ends and all memory is released. – Rich Remer May 26 '21 at 16:43
Things have been changed but it was not mentioned in the document
--daemon Run the worker in daemon mode (Deprecated)
now by default php artisan queue:work
runs in daemon mode,
so queue:work
continue processing jobs without ever re-booting the framework
for run it once command is,
php artisan queue:work --once

- 9,710
- 4
- 47
- 48
-
not true, it does not run in deamon mode, it keeps the user interface open and does not run in background... – davefrassoni Apr 23 '21 at 18:37
The most important difference is that queue:work --daemon
does not restart the framework on each job, but queue:listen
does. In fact, listen
starts a whole new Laravel process for each job.
Try for yourself: Open 2 terminals and run work --daemon
in one and listen
in the other. The work
window will execute jobs much faster than listen
.

- 964
- 2
- 14
- 26
As of Laravel 5.7 a new option --stop-when-empty
has been added to the queue:work
command. When using this option the current queue will be processed until it's empty, then the command will exit.
According to the documentation:
The --stop-when-empty option may be used to instruct the worker to process all jobs and then exit gracefully. This option can be useful when working Laravel queues within a Docker container if you wish to shutdown the container after the queue is empty:
php artisan queue:work --stop-when-empty

- 3,705
- 2
- 14
- 24