Running Laravel queues automatically [duplicate]

我的梦境 提交于 2019-12-24 00:54:20

问题


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.


回答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.




回答2:


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)



来源:https://stackoverflow.com/questions/34513072/running-laravel-queues-automatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!