Run php script as daemon process

后端 未结 14 1687
-上瘾入骨i
-上瘾入骨i 2020-11-22 11:36

I need to run a php script as daemon process (wait for instructions and do stuff). cron job will not do it for me because actions need to be taken as soon as instruction arr

14条回答
  •  礼貌的吻别
    2020-11-22 12:13

    You can

    1. Use nohup as Henrik suggested.
    2. Use screen and run your PHP program as a regular process inside that. This gives you more control than using nohup.
    3. Use a daemoniser like http://supervisord.org/ (it's written in Python but can daemonise any command line program and give you a remote control to manage it).
    4. Write your own daemonise wrapper like Emil suggested but it's overkill IMO.

    I'd recommend the simplest method (screen in my opinion) and then if you want more features or functionality, move to more complex methods.

提交回复
热议问题