|
发表于 2020-3-16 02:20:00
|
显示全部楼层
#!/bin/bash) z, e/ |" U O* F
dt=`date '+%d/%m/%Y %H:%M:%S'`! l# F c1 {* v& F* N
sleep 60;
+ R/ Z& R* A$ n0 E> /result.txt/ ]2 h& ]* Z& R: o) V6 F. P
num=`ping -c20 192.168.3.1 | tail -2 | head -1 | cut -f 3 -d"," | cut -f 1 -d"%" | cut -f 2 -d" "`
+ T- E- `2 Q/ I! Kecho $num- T6 D7 W7 `4 i1 j0 i2 w7 J
echo $?5 z4 X8 { u, t" A
if [ $? -eq 0 -a $num -eq 0 ]; then. Y1 t3 D% n& c" r! R
echo "$dt ok" >> /result.txt8 E0 R4 G* g- z, q3 g3 P& k
else
! q; w2 z0 B ^# }: i# h echo "$dt noip loss $num reboot" >> /result.txt9 L, m6 G. ]1 B0 a, Q. M; y
reboot
0 Q" O4 q! S- T) ^fi |
|