简介
python-daemon实现Unix守护进程。 参考: 了解更多
该库实现了PEP 3143“标准守护进程库”的良好行为守护进程规范。
DaemonContext实例保存程序的行为和配置的进程环境。
快速入门
import time # 资料学习交流群 QQ 519970686 #
with daemon.DaemonContext():
f = open("/tmp/test.log",'w')
while True:
f.write('''
Library to implement a well-behaved Unix daemon process.
This library implements the well-behaved daemon specification of PEP 3143, “Standard daemon process library”.
A well-behaved Unix daemon process is tricky to get right, but the required steps are much the same for every daemon program. A DaemonContext instance holds the behaviour and configured process environment for the program; use the instance as a context manager to enter a daemon state.
''')
f.write("{0}\n".format(time.ctime(time.time())))