Python 2.7.9
daemonize-2.3.1
https://pypi.python.org/pypi/daemonize
tar xvzf daemonize-2.3.1.tar.gz
cd daemonize-2.3.1
python setup.py install
python
import daemonize
#!usr/bin/python
from time import sleep
import os,sys
from daemonize import Daemonize
pid="/root/python/daemonize/test3.pid"
def wlog():
f=open('/root/python/daemonize/test','a')
f.write('11')
f.close()
def wlog2():
f=open('/root/python/daemonize/test2','a')
f.write('222')
f.close()
def main():
while 1:
sleep(5)
wlog()
while 2:
sleep(5)
wlog2()
daemon = Daemonize(app='test_app',pid=pid ,action=main)
daemon.start()
daemon.get_pid()
daemon.is_running()