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]

沒有留言:

Automatically classify folders by file name (windows Bash)

  REM List file names, sorted by file name--------- dir /b /on > list.txt REM Find JPG files findstr ".JPG" list.txt > targe...