文件名称:ipchange.sh
文件大小:470B
文件格式:SH
更新时间:2022-09-25 04:11:09
公网ip变化检测
#!/bin/sh cd /usr/local/bin mkdir -p .ip/ touch .ip/ip.txt touch .ip/1.log touch .ip/email.txt IPADDRESS=$(curl -s http://ipv4.icanhazip.com) OLDIP=`cat .ip/ip.txt` if [ $IPADDRESS == $OLDIP ] then echo "`date -u` not changed" else echo $IPADDRESS > .ip/ip.txt echo "$OLDIP=>$IPADDRESS" >> .ip/email.txt echo "`date -u` changed" >> .ip/email.txt curl "http://ipv4.icanhazip.com"(更换成你需要的接口即可域名自动解析邮件发送等) echo "`date -u` changed" >> .ip/1.log echo "Send email successfully!" fi