jin-521

两个思路:

一、定时执行监控脚本

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

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

分类:

技术点:

相关文章:

  • 2023-02-27
  • 2021-04-04
  • 2021-11-22
  • 2021-10-06
  • 2022-12-23
  • 2021-12-23
  • 2021-05-29
  • 2021-10-25
猜你喜欢
  • 2021-12-23
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
  • 2021-08-02
  • 2021-07-31
相关资源
相似解决方案