Shell 脚本监控服务器
in web with 0 comment
Shell 脚本监控服务器
in web with 0 comment

shell监控网卡状态,故障时自动重启网卡
树莓派保持网络连接shell脚本

#! /bin/bash
#检测网络连接
log=/root/network.log
#判断输出日志文件是否存在
if [ ! -f ${log} ]
then
   touch ${log}
fi
ping -c 1 192.168.1.1 > /dev/null 2>&1
if [ $? -eq 0 ];
  then
    echo `date` 检测网络正常 >> ${log}
else
    echo `date` 检测网络异常 >> ${log}
    reboot
fi
Responses