forked from china-testing/python-api-tesing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdaemon1.py
More file actions
21 lines (17 loc) · 842 Bytes
/
daemon1.py
File metadata and controls
21 lines (17 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Author: xurongzhong#126.com wechat:pythontesting qq:37391319
# CreateDate: 2018-02-08 qq群: 144081101
# daemon1.py
import daemon
import time
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())))
time.sleep(1)