|
发表于 2020-3-16 02:20:00
|
显示全部楼层
#!/bin/bash
+ k1 c u$ w Ddt=`date '+%d/%m/%Y %H:%M:%S'`( a s7 E. L% O2 m4 ]1 D4 d
sleep 60;
5 \0 O8 f0 e2 U; A5 A5 F- q3 d% R> /result.txt
1 i( f+ t9 X E2 g6 _num=`ping -c20 192.168.3.1 | tail -2 | head -1 | cut -f 3 -d"," | cut -f 1 -d"%" | cut -f 2 -d" "`& G7 X! G) @7 `0 ], }- u' c
echo $num, E+ W( O! j R5 ?
echo $?, D1 U4 ?& U, z% g
if [ $? -eq 0 -a $num -eq 0 ]; then
# g$ f( O3 Z; A) J) X9 q echo "$dt ok" >> /result.txt& t: S8 l6 D, {! A. a. p
else! J6 F* v) ]$ {
echo "$dt noip loss $num reboot" >> /result.txt
! y f( T+ x# _# } reboot3 k( `# u+ Y r; p. L- j& k
fi |
|