神剑山庄资源网 Design By www.hcban.com
Linux 检测服务器是否连接着网络
摘要: 每隔5分钟检测一次服务器是否连接着网络,如果三次检测都没有网络"htmlcode">
#!/bin/bash # 检测服务器是否连接着网络,如果网络不通 则 3次后 关机 # crontab -e # */5 * * * * ./check.sh echo "Starting test network was clear..." if test -e ./checkInfo then echo "CheckInfo File Exist..." else cat /dev/null > ./checkInfo fi last_res=`head -1 ./checkInfo` checkInternet(){ ping_res=1 for url in "8.8.8.8" "61.139.2.69" "114.114.114.114" "168.95.1.1" "223.5.5.5" "180.76.76.76" do echo "PING ${url}" ping=`ping -c 3 ${url}|awk 'NR==7 {print $4}'` if [ ${ping} -eq 0 ] then ping_res=1 else ping_res=2 fi if [ ${ping_res} -eq 2 ] then break fi done return ${ping_res} } checkInternet result="$" if [ ${result} -eq 1 ] then if [ "${last_res}" = "1" ] then echo "2" > ./checkInfo elif [ "${last_res}" = "2" ] then cat /dev/null > ./checkInfo init 0 else echo "1" > ./checkInfo fi else cat /dev/null > ./checkInfo fi
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
神剑山庄资源网 Design By www.hcban.com
神剑山庄资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
神剑山庄资源网 Design By www.hcban.com
暂无Linux 检测服务器是否连接着网络的评论...
更新日志
2024年09月20日
2024年09月20日
- 曾轶可.2011-一只猫的旅行【天娱传媒】【WAV+CUE】
- 黑神话悟空上品狼刺客精魄获取方法一览|上品狼刺客精魄收集攻略
- 视觉小说《神椿市建设中REGENERATE》将于2025年2月20日发售
- 黑神话悟空上品鼠弩手精魄获取方法一览|上品鼠弩手精魄收集攻略
- 中国音乐地图听见世界非物质文化遗产《非遗HQCD》wav
- 中国民乐合奏作品集《华夏之音HQ》头版限量编号[WAV+CUE]
- [电影原声带]黎允文《天将雄师》[FLAC+CUE]
- 曝NS继任机型已进入量产阶段:已花了30亿日元
- 不是Switch2?曝《马里奥惊奇》NS捆绑包即将公开
- 暖心任天堂!网友Switch维修返还时贴纸被完好保留
- 《国语老歌 经典对唱情歌 2CD》[WAV/分轨][1.1GB]
- 《刀郎 翻唱精选华语专辑 披着羊皮的狼 》[WAV+CUE][430MB]
- 《真的田震 中国乐坛红极一时的歌者 精品集》[WAV+CUE][300MB]
- 群星.1995-新滚石九大天王之情歌大全【滚石】【WAV+CUE】
- 群星.1993-滚石九大天王十二出好戏·纵夏欢唱【滚石】【WAV+CUE】