标签:定义 cut main tmp list article reg print details
#!/bin/bash
#检测whois命令是否存在,不存在则安装jwhois包
is_install_whois()
{
which whois &> /dev/null
if [ $? -ne 0 ];then
yum install -y jwhois
fi
}
is_install_whois
#定义需要被检测的域名列表
domainlist=`cat /tmp/dns.txt`
#检测域名到期时间并通知
for domain in ${domainlist[*]};do
#取出域名过期时间
expire_date=`whois $domain | grep "Registry Expiry Date" | awk ‘{print $4}‘`
#if [ -z "$expire_date" ];then
# expire_date=`whois $domain | grep ‘Registry Expiry Date‘|awk ‘{print $4}‘|cut -d ‘T‘ -f 1`
#fi
#转换成时间戳
sleep 1
expire_date_timestamp=`date -d $expire_date +%s`
#以时间戳的形式显示当前时间
sleep 1
now=`date ‘+%s‘`
#域名到期剩余天数
sleep 1
time_left=$[$[$expire_date_timestamp - $now]/86400]
#if [ $time_left - le 7 ];then
echo -e "$domain $time_left"
# fi
done
#################################
参考地址 https://blog.csdn.net/weixin_34283445/article/details/92512998
标签:定义 cut main tmp list article reg print details
原文地址:https://www.cnblogs.com/yanzi2020/p/14549976.html