check.py 582 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import time
  4. import os
  5. timeSleep = 15
  6. def popen(command, bg=False):
  7. string = command
  8. if bg == True:
  9. command = command + ' &'
  10. process = os.popen(command)
  11. output = process.read()
  12. process.close()
  13. return output
  14. # 定时执行进程
  15. def process():
  16. command = 'python /www/api/daemon.py 1>/dev/null 2>&1 &'
  17. check = 'ps -ef | grep daemon.py | grep -v grep | wc -l'
  18. value = int(popen(check))
  19. if value == 0:
  20. popen(command)
  21. process()