Linux下的应用进程监控,监控进程有哪些


两个思路:

一、定时执行监控脚本

  采用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

  设置开机启动:

  echo "/bin/bash /root/status" >> /etc/rc.d/rc.local

  chmod +x /etc/rc.d/rc.local

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

相关内容

    暂无相关文章