|
|
发表于 2020-3-16 02:20:00
|
显示全部楼层
#!/bin/bash1 D7 Y* ]5 `0 c* V) X- y
dt=`date '+%d/%m/%Y %H:%M:%S'`
, H/ z- H) T8 G3 }& _0 B; P1 xsleep 60;* }( Z9 C: C! p3 K6 A
> /result.txt
' _ W& e; R2 J. lnum=`ping -c20 192.168.3.1 | tail -2 | head -1 | cut -f 3 -d"," | cut -f 1 -d"%" | cut -f 2 -d" "`
# b$ H1 b0 m% q/ w/ S7 Yecho $num
* W7 Z k) F( cecho $?, ~$ T/ x) d0 t; }- ^! J& q
if [ $? -eq 0 -a $num -eq 0 ]; then; a; F0 n0 P' R* @
echo "$dt ok" >> /result.txt
7 h$ C( @1 @1 D) J( `+ melse! {: O+ t/ M; e
echo "$dt noip loss $num reboot" >> /result.txt
; k/ w S6 b- d7 d) {8 N! g! V, S reboot" L+ a0 } G% @6 d g) p; h
fi |
|