python进程监控及恢复

#!/usr/bin/env python 
# -*- coding: utf-8 -*-

import os 
process="/tmp/tomcat.lock"        
  os.system("ps -ef|grep apache-tomcat-6.0.35|grep -v grep >%s" % process) #将进程信息写入lock文件 
if not(os.path.getsize(process)):	#判断文件大小,当tomcat没有运行时上一步写入lock的内容为空 
    os.system("/tomcat/apache-tomcat-6.0.35/bin/startup.sh")	#启动进程
posted @ 2017-03-23 09:20  flanker_X  阅读(283)  评论(0编辑  收藏  举报