skip to Main Content

I’m working with a Laravel project and I need to run the php artisan queue:work command continuously, even when there are no jobs in the queue. I have already set up a Windows Task Scheduler task to run the command, but the problem is that once the job queue is empty and there are no jobs to process, the worker stops.

I want to make sure the worker continues running indefinitely, so when new jobs are added to the queue, the worker will automatically pick them up without needing to manually restart it.

Is it possible to configure Windows Task Scheduler or modify the queue worker behavior to ensure it remains running even when there are no jobs in the queue?

Here’s what I’ve tried so far:

  • I’ve set up the task to run php artisan queue:work --daemon but the task still stops when the queue is empty.

  • I’ve checked the Laravel documentation, but I couldn’t find any specific solution for this scenario.

Has anyone encountered this issue before or can provide some guidance?

Additional details:

  • PHP version: 7.2

  • Using the default database queue driver

  • Task scheduler is set to at startup

Thanks in advance for any suggestions or solutions!

2

Answers


  1. Maybe you can try turn it into a service with the nssm

    here is a guide for that

    Login or Signup to reply.
  2. You don’t need to worry about the --daemon flag anymore since it’s been outdated for ages. The official Laravel documentation doesn’t have a solid answer for handling long-running background tasks on Windows. It recommends using supervisors, but those are only for UNIX systems.

    But you could check out NSSM (Non-Sucking Service Manager). I stumbled upon a helpful thread last year that helped me – https://laracasts.com/discuss/channels/general-discussion/best-way-to-use-queues-on-a-windows-server?page=1&replyId=419211

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search