python定时检查 python定时检查启动某个exe程序适合检测exe是否挂了

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

python定时检查 python定时检查启动某个exe程序适合检测exe是否挂了

  2021-03-18 我要评论
想了解python定时检查启动某个exe程序适合检测exe是否挂了的相关内容吗,在本文为您仔细讲解python定时检查的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:python定时检查,定时,下面大家一起来学习吧。
详见代码如下:
复制代码 代码如下:

import threading
import time
import os
import subprocess
def get_process_count(imagename):
p = os.popen('tasklist /FI "IMAGENAME eq %s"' % imagename)
return p.read().count(imagename)
def timer_start():
t = threading.Timer(120,watch_func,("is running..."))
t.start()
def watch_func(msg):
print "I'm watch_func,",msg
if get_process_count('main.exe') == 0 :
print subprocess.Popen([r'D:\shuaji\bin\main.exe'])
timer_start()
if __name__ == "__main__":
timer_start()
while True:
time.sleep(1)

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们