Run php script as daemon process

 

  1. Supervisor 推荐!活跃度比较高。但是目前依赖Python
  2. upstart 类似init的替换品
  3. daemon tools
  4. php simple daemon
  5. linux tool: start-stop-daemon 比较简单的一种
  6. nohup php script.php & 不可靠的一种
  7. pear package System_Daemon 最后更新日期2012-03-13,估计没人维护了,可以了解一下,其使用介绍的文章

 

upstart example

How to set it up:

Create a new script file at /etc/init/myphpworker.conf. Here is an example:

# Info
description "My PHP Worker"
author      "Jonathan"

# Events
start on startup
stop on shutdown

# Automatically respawn
respawn
respawn limit 20 5

# Run the script!
# Note, in this example, if your PHP script returns
# the string "ERROR", the daemon will stop itself.
script
    [ $(exec /usr/bin/php -f /path/to/your/script.php) = 'ERROR' ] && ( stop; exit 1; )
end script
Starting & stopping your daemon:

sudo service myphpworker start
sudo service myphpworker stop
Check if your daemon is running:

sudo service myphpworker status

 

转载于:https://my.oschina.net/swingcoder/blog/851740

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值