|
发表于 2020-3-16 02:20:00
|
显示全部楼层
#!/bin/bash8 `. e0 a( [ h2 I9 I
dt=`date '+%d/%m/%Y %H:%M:%S'`
- v5 Y# z2 k5 a7 d7 m tsleep 60; V( [" O D0 t0 V
> /result.txt5 O6 f% `* N( b2 u# [! g
num=`ping -c20 192.168.3.1 | tail -2 | head -1 | cut -f 3 -d"," | cut -f 1 -d"%" | cut -f 2 -d" "`$ s2 f' H+ e! @- @$ w
echo $num1 l0 d# G. `1 {" B
echo $?
, b, [: g# x1 X! m8 l0 Nif [ $? -eq 0 -a $num -eq 0 ]; then6 r, \% c" [4 L9 B; n1 @, f
echo "$dt ok" >> /result.txt2 L- ^- x; [: g* I v4 v
else2 m3 {1 D5 D8 ~0 a0 ?! o3 B1 {
echo "$dt noip loss $num reboot" >> /result.txt' P* y) z8 x2 G; l4 B# y
reboot
0 |% |0 Y. H2 {# M: e5 p) {fi |
|