- Supervisor 推荐!活跃度比较高。但是目前依赖Python
- upstart 类似init的替换品
- daemon tools
- php simple daemon
- linux tool: start-stop-daemon 比较简单的一种
- nohup php script.php & 不可靠的一种
- 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