python定时检查启动某个exe程序(如果exe挂了)
2013-01-10 22:32
811 查看
详见代码如下:
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)
相关文章推荐
- python定时检查启动某个exe程序适合检测exe是否挂了
- 程序一启动检查网络,如果没有网络就退出程序
- 定时启动多个cmd的python程序,并且批处理关闭各个程序,一键启动conda虚拟环境和运行多个python
- 使用PyInstaller——Python程序转换为EXE
- 定时自动启动外部应用软件并限时关闭此软件程序
- Android adb.exe程序启动不起来,如何处理
- VS2012中出现“无法启动程序...debug\abc.exe,系统找不到指定文件”的问题!
- python--- 如何将自己的程序打包成exe ?
- shell 脚本监控程序是否正在执行, 如果没有执行, 则自动启动该进程
- Windows定时运行python程序
- 使用 PyInstaller 把python程序 .py转为 .exe 可执行程序
- Python 3.6打包成EXE可执行程序
- 新装python环境启动django程序报错
- 如何启动app和exe程序
- python 生成exe程序
- 项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次
- 通过分析exevc系统调用处理过程来理解Linux内核如何装载和启动一个可执行程序
- 【问题】无法启动程序"XXX.exe",拒绝访问,解决方案
- 如何将Python的py程序打包成跨平台的exe文件