标签:pop ftime import art python cmd exception start lines
Python 监控nginx服务是否正常
#!/usr/bin/env python import os, sys, time from time import strftime while True: try: ret = os.popen(‘ps -C nginx -o pid,cmd‘).readlines() if len(ret) <2: os.system("service nginx start") sys.exit(0) except Exception,ex: print strftime("%Y-%m-%r %H:%M") sys.exit(0)
标签:pop ftime import art python cmd exception start lines
原文地址:http://www.cnblogs.com/liuyansheng/p/6203751.html