|
|
发表于 2020-3-16 02:20:00
|
显示全部楼层
#!/bin/bash
; t7 t; Q7 A- Hdt=`date '+%d/%m/%Y %H:%M:%S'`/ C" M. y3 n/ a
sleep 60;, g% {( F% O5 p( Q% A5 x6 Y
> /result.txt
. Q3 ]2 }+ s. B- N# C9 E; y( Rnum=`ping -c20 192.168.3.1 | tail -2 | head -1 | cut -f 3 -d"," | cut -f 1 -d"%" | cut -f 2 -d" "`
8 d$ c6 Y w/ }: z0 N4 o& y' ^$ c4 k6 w& {echo $num
. O: n+ _" Z% hecho $?
{5 l; U) [5 j# Bif [ $? -eq 0 -a $num -eq 0 ]; then- I0 ?7 D/ y/ y8 Y" c4 P3 d
echo "$dt ok" >> /result.txt/ k; m8 ~$ v- `" @8 y: e; x. ?
else
# C; |6 H% G9 ^( _3 l9 c echo "$dt noip loss $num reboot" >> /result.txt& {6 M9 s1 O, b( a& v6 {
reboot
`2 b% s+ X1 Y2 M/ K5 Ifi |
|