使用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]

留言

這個網誌中的熱門文章

error message : configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: "%)']/following::android.widget.EditText"

OSError: [Errno 22] Invalid argument: