#!/bin/bash
if [! -f /root/ip.txt];then
echo $(date +%Y"."%m"."%d" "%k":"%M":"%S) > /root/ip.txt
curl http://members.3322.org/dyndns/getip >> /root/ip.txt
fi
while var=$(curl http://members.3322.org/dyndns/getip) || true; do
iptxt=$(tail -1 /root/ip.txt)
#echo $iptxt
#echo $var
if [ $var != $iptxt ];then
echo $(date +%Y"."%m"."%d" "%k":"%M":"%S) >> /root/ip.txt
echo "$var" >> /root/ip.txt
#echo "record ip"
#else
#echo "ip is same"
fi
sleep 60s
done
linux shell脚本 取得外网IP并保存到文件
最新推荐文章于 2023-11-15 15:21:03 发布