|
|
发表于 2020-3-16 02:20:00
|
显示全部楼层
#!/bin/bash; Q* o- } e. @" F1 k- r$ p" V
dt=`date '+%d/%m/%Y %H:%M:%S'`9 T0 |/ V, F) |& V) g V6 {
sleep 60;
, G+ e& S0 v, G3 s7 T> /result.txt' g! E7 W) r2 D" s" [
num=`ping -c20 192.168.3.1 | tail -2 | head -1 | cut -f 3 -d"," | cut -f 1 -d"%" | cut -f 2 -d" "`' H6 L' ?# `* C" Z9 i1 t
echo $num
5 I/ P x- e! Qecho $?
, W, d B/ {) ^) G7 [if [ $? -eq 0 -a $num -eq 0 ]; then0 \$ n# I7 \0 q, Z* K
echo "$dt ok" >> /result.txt
. @( A5 C' g( X. nelse9 S; j H3 ~1 w7 K
echo "$dt noip loss $num reboot" >> /result.txt
% \1 G( C O$ B; B, w reboot
7 |( }( C% E, R7 N7 ~$ Hfi |
|