2016年3月24日 星期四

使用python 監控程式, 實現watchdog功能



import os, sys, time
while True:
    time.sleep(4)
    try:
        ret = os.popen('ps -C sample -o pid,cmd').readlines() # 所需監控程式
        if len(ret) < 2:
            time.sleep(3)
            os.system("~/remote/sample host SID rdz.orbwebsys.com") # 程式重新啟動
    except:
        print "Error", sys.exc_info()[1]

沒有留言:

 Ubuntu has a mechanism, that is, the installed network card (NIC) will be renamed to another name when the system is booted. Although there...