2

I have implemented Laravel queue.The thing is i have to run the command php artisan queue:listen every time.Is there any way that the jobs get executed automatically without running any command.

Sameer Sheikh
  • 499
  • 1
  • 6
  • 16
  • What OS are you using? – Bogdan Dec 29 '15 at 14:30
  • Then you can follow the the detailed instructions from the Laravel Documentation on how to install and use [Supervisor](https://laravel.com/docs/5.1/queues#supervisor-configuration) to manage the queue listener. – Bogdan Dec 29 '15 at 14:36

2 Answers2

3

Here's a one-liner to put into your crontab (let it run, let say, every 5 minutes):

cd /path/to/your/project && jobs -l | grep `cat queue.pid` || { nohup /usr/bin/php artisan queue:listen & echo $! > queue.pid; }

two variables here: 1. /path/to/your/project -- is your Laravel project root. Effectively, the folder, where php artisan would work; 2. /usr/bin/php -- path to PHP executable on the server (which php)

pilat
  • 1,094
  • 1
  • 10
  • 17
1

Yes, if you use Linux you can use for example supervisor which will run php artisan queue:listen (you need to add this command to supervisor configuration file) and it will make sure all the time this command is running.

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291