提前把我们要检查的网络的ip地址写入到ip.txt文本中,格式如下:
日后,如有网络增加地址,可直接写入此文本中;
检查脚本如下:
#!/bin/bash #author: lijinzhu #this is a check network script. dt=$(date +%Y%m%d) [ -f /home/vsftproot/check_${dt}.log ] && echo "Clean up expired file: $(ls /home/vsftproot/check_${dt}.log) success... Start check..." && rm -rf /home/vsftproot/check_${dt}.log echo "system is checking the network service" echo "Please wating..." sleep 2 while read line do if ping -w 1 -c 1 $line &>/dev/null; then echo "$line is up" >> /home/vsftproot/check_${dt}.log else echo "$line is down" >> /home/vsftproot/check_${dt}.log fi done < /root/ip.txt echo "" echo "done....you can see "/home/vsftproot/check_${dt}.log""
扫描二维码关注公众号,回复:
12135646 查看本文章
