源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

写了个监控nginx进程的Python脚本

  • 时间:2021-08-04 19:57 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:写了个监控nginx进程的Python脚本
[u]复制代码[/u] 代码如下:
#!/usr/bin/env python import os, sys, time while True: time.sleep(3) try: ret = os.popen('ps -C nginx -o pid,cmd').readlines() if len(ret) < 2: print "nginx process killed, restarting service in 3 seconds." time.sleep(3) os.system("service nginx restart") except: print "Error", sys.exc_info()[1]
设置文件可执行属性,加入到/etc/rc.local,总算放心了。 这种方法还可以监控别的进程,我相信应该有现成的监控软件,但是我觉得写个脚本更方便。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部