码迷,mamicode.com
首页 > 其他好文 > 详细

阿铭每日一题 day 13 20180124

时间:2018-01-24 19:53:50      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:day   cto   body   print   col   dev   version   访问   dom   

技术分享图片

 

 

方法一:

#!/bin/bash
#Author: Yang YuanQiang
#Blog1: http://aqiang.blog.51cto.com
#Blog2: http://www.cnblogs.com/ivan-yang/
#Time: 2018-01-24 13:50:53
#Name: day13_20180124.sh
#Version: V1.0
#Description: This is a script.

echo "Useage $0 域名,如: $0 baidu.com"
if [ $# -ne 1 ]
then
    exit
fi
which whois > /dev/null 2> /dev/null
if [ $? -ne 0 ]
then
    yum install -y whois
fi
domain_date=`whois $1 |grep "Expiry Date"|awk {print $4}|cut -d T -f 1`
today=`date "+%F"`
expiry_date=`date -d "7 day ago ${domain_date}" +%F`
if [ ${expiry_date} == ${today} ]
then
    echo "$1 域名一周后到期,请及时续费,保证网站正常访问" |mail -s "$1 域名到期通知" test@163.com
fi

 

 

方法二:

#!/bin/bash
#Author: Yang YuanQiang
#Blog1: http://aqiang.blog.51cto.com
#Blog2: http://www.cnblogs.com/ivan-yang/
#Time: 2018-01-24 17:05:09
#Name: day13_2_20180124.sh
#Version: V1.0
#Description: This is a script.

t1=`date +%s`
is_install_whois()
{
    which whois > /dev/null 2> /dev/null
    if [ $? -ne 0 ]
    then
        yum install -y whois
    fi
}

notify()
{
    e_d=`whois $1 | grep "Expiry Date" |awk {print $4} |cut -d T -f 1`
    e_t=`date -d "$e_d" +%s`
#提取一周前的时间
    n=`echo "86400*7"|bc`
    e_t1=$[$e_t-$n]
    if [ $t1 -ge $e_t1 ] && [ $t1 -lt $e_t ]
    then
        echo "$1 域名一周后"到期,请及时续费,保证网站正常访问" |mail -s "$1 域名到期通知" test@163.com"
    fi
}

is_install_whois
notify pengqi.club

 

阿铭每日一题 day 13 20180124

标签:day   cto   body   print   col   dev   version   访问   dom   

原文地址:https://www.cnblogs.com/ivan-yang/p/8342705.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!