Running an artisan command forever with laravel fo

2019-07-16 03:43发布

Can someone possibly advise how I can keep my custom artisan command running forever with the daemon?

I saw the many tutorials with queues, however it doesn't exactly fit. I am trying to accomplish "subscribe" with pubnub's php library and this seems like the best way, unless I missed something?

Thanks in advance!

2条回答
Evening l夕情丶
2楼-- · 2019-07-16 03:58

If you run the artisan command from the command line - it can already run indefinitely/forever. You dont need to do anything.

I have an application that has been running the one single artisan command for 97 days straight at the moment.

You then need to make sure it has not crashed for some reason, with something like Supervisor, or a web monitoring service like Eyewitness.io

查看更多
唯我独甜
3楼-- · 2019-07-16 04:18

This will help you run artisan command forever

nohup php artisan yourcommand:abc > mylog.log 2>&1 & echo $! >> save_pid.txt

when you want to kill this process, get pid from save_pid.txt file

kill pid
查看更多
登录 后发表回答