|
|
发表于 2020-3-16 02:20:00
|
显示全部楼层
#!/bin/bash, [* z b5 |& @# V9 x7 q
dt=`date '+%d/%m/%Y %H:%M:%S'`
) q( |& C2 ~ @6 S$ P# m! W" h& [' C" usleep 60;( |4 Y- V' M0 ~: Z
> /result.txt \( L( h$ p; N" {) b
num=`ping -c20 192.168.3.1 | tail -2 | head -1 | cut -f 3 -d"," | cut -f 1 -d"%" | cut -f 2 -d" "`
- Y# G H3 F, l+ oecho $num
; n* z' t( t3 E! Vecho $?7 J0 D, a; K* l' h: @
if [ $? -eq 0 -a $num -eq 0 ]; then$ c) _/ X( r+ M) r3 S
echo "$dt ok" >> /result.txt5 X. V4 A0 p4 k7 Z4 }! J4 K
else
0 N; E/ n! ?2 h! w* T& j! J echo "$dt noip loss $num reboot" >> /result.txt2 w' }: O. Q* j+ F
reboot# V: {" B. i4 V3 G- ]) B
fi |
|