check.py 585 B

1234567891011121314151617181920212223
  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. def process():
  15. command = 'python /data/dm/container/web/master_cron.py 1>/dev/null 2>&1 &'
  16. check = 'ps -ef | grep master_cron.py | grep -v grep | wc -l'
  17. value = int(popen(check))
  18. if value == 0:
  19. popen(command)
  20. process()