设为首页 加入收藏

TOP

Linux下的应用进程监控
2019-10-09 20:03:33 】 浏览:18
Tags: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

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

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇每天3分钟操作系统修炼秘籍(3).. 下一篇Linux简单检查服务运行脚本

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目