python 守护进程,监控进程
2015-03-04 17:25
344 查看
守护进程代码:
其中config是一个文件,里面的每一行是要监控的exe文件路径:
eg: C:\Program Files (x86)\Jenkins\jenkins.exe
监控进程:
import time, os import subprocess def run(): while True: taskList = os.popen('tasklist').read() for path, exe in [os.path.split(line.strip()) for line in open('config') if line.strip()]: if exe not in taskList: subprocess.Popen(u'start /d"%s" %s' % (path, exe), shell = True) time.sleep(60) run()
其中config是一个文件,里面的每一行是要监控的exe文件路径:
eg: C:\Program Files (x86)\Jenkins\jenkins.exe
监控进程:
import time, os import subprocess def run(): i = 0 while True: filehandler = open(os.path.join('c:\logs', 'bollist' + str(i) + '.txt'), 'w') a = subprocess.Popen('tasklist /fi "Imagename eq cmd.exe" /v ', stdout= filehandler) i = i+1 time.sleep(10) run()
相关文章推荐
- python守护进程监控hive server(类形式)
- python守护进程监控hive server
- 【浅谈守护进程】Demo:后台监控程序-- Python实现
- 发个在linux下用python写守护进程的好东东(转)
- python 写的一个Ice服务端在linux下面的守护进程程序
- Python实现的守护进程
- Python模块整理(六):守护进程
- python 监控进程,结束后发送邮件
- C语言写监控守护进程
- 怎样利用Python制作守护进程
- python 守护进程
- python跑守护进程
- Python 监控 DB 服务器信息(cpu, 磁盘,进程,alert log) 脚本
- LR监控服务器以及在服务器上安装rstatd守护进程
- Python进程的守护进程实施方案的详细介绍
- [转] 使用Python写Linux的守护进程(daemon)
- 用Python写个进程监控程序
- Python 监控 DB 服务器信息(cpu, 磁盘,进程,alert log) 脚本
- 用python编写daemon监控进程并自动恢复(附Shell版)
- 写了个监控nginx进程的Python脚本