|
发表于 2020-3-16 02:20:00
|
显示全部楼层
#!/bin/bash$ {& @- h+ {0 P% V, K0 b
dt=`date '+%d/%m/%Y %H:%M:%S'`- X2 L5 _$ P2 @, p+ _0 w7 P: _8 p9 J
sleep 60;
: b! ?" _7 W* b/ @4 R, z# o" ~1 M4 d> /result.txt$ C+ A0 F* y& N& s
num=`ping -c20 192.168.3.1 | tail -2 | head -1 | cut -f 3 -d"," | cut -f 1 -d"%" | cut -f 2 -d" "`
( \5 D" h% z* k" r, Techo $num# O j6 m, N& L/ Q. E0 B, N! ~
echo $?. R3 S4 C" S7 y5 f: A F$ [5 }
if [ $? -eq 0 -a $num -eq 0 ]; then
0 R2 y6 F9 ?" p8 p: w! G echo "$dt ok" >> /result.txt
& ?0 }* Z% {9 @: q( O6 P& I2 |" Telse
' }& P/ P' h* f! d" u3 w echo "$dt noip loss $num reboot" >> /result.txt5 L! ] [" ^) C9 c, T) t
reboot6 w8 L/ o/ t+ L0 d
fi |
|