|
发表于 2019-10-12 20:06:50
|
显示全部楼层
老哥 我优化了下,丢包重启。。。/ A& u7 x8 F$ Z+ l E6 c
#!/bin/bash$ E$ Y+ v7 m+ r. t& P, ^
dt=`date '+%d/%m/%Y %H:%M:%S'`: Z: @) i+ J, Z: U: @$ r
sleep 60
& P; W0 }# |& w; `) P& \6 |> /result.txt# G! B7 o5 U0 O- u5 r
num=`ping -c20 192.168.2.1 | tail -2 | head -1 | cut -f 3 -d"," | cut -f 1 -d"%" | cut -f 2 -d" "`) E3 ~0 W: O) |9 Z' G; Z: ^
echo $num) C c% p+ v# _3 L
echo $?# S X) C2 S8 e+ U0 `0 W8 t c
if [ $? -eq 0 -a $num -eq 0 ]; then
2 _; @8 `/ U' `7 W& k- v( v' b J echo "$dt ok" >> /result.txt
" [; g8 S& Y& C& r3 ^- y. gelse* p2 f4 ]9 ?* U- g
echo "$dt noip loss $num reboot" >> /result.txt
9 y% U* o% }% A2 L: l, o3 s$ I reboot; G6 G# b1 s( g0 y3 p
fi |
评分
-
查看全部评分
|