Linux下的应用进程监控

时间:2019-10-08 11:36:39   收藏:0   阅读:73

两个思路:

一、定时执行监控脚本

  采用centos自带的crontab根据需要定时执行status.sh脚本

  #!/bin/bash

  status=$(ps -aux | grep "rsync --daemon" | grep -v "grep" | wc -l)

  if [ $status -eq 0 ];then

    systemctl restart rsyncd.service
  else
    exit 0;
  fi

 

二、后台执行的方式

  sh status.sh &

  #!/bin/bash

  while true

  do

    ps -aux | grep "rsync --daemon" | grep -v "grep" | wc -l
    if [ $? -ne 0 ]; then
      systemctl restart rsyncd.service
    fi
    sleep 10
  done


目前大致思路就是这两种,有其他思路的还望留言讨论下!

原文:https://www.cnblogs.com/jin-521/p/11634294.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!