zoukankan      html  css  js  c++  java
  • 阿铭每日一题 day 13 20180124

    方法一:

    #!/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_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
    }
    
    is_install_bc()
    {
        which bc > /dev/null 2> /dev/null
        if [ $? -ne 0 ]
        then
            yum install -y bc
        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 域名在${e_d}到期,请及时续费,保证网站正常访问" |mail -s "$1 域名到期通知" aming_test@163.com
        fi
    }
    
    is_install_whois
    is_install_bc
    notify aminglinux.com

    方法二:

    #!/bin/bash
    #Author: Yang YuanQiang
    #Blog1: http://aqiang.blog.51cto.com
    #Blog2: http://www.cnblogs.com/ivan-yang/
    #Time: 2018-01-24 17:10:09
    #Name: day13_2_20180124.sh
    #Version: V1.0
    #Description: This is a script.
    
    
    t1=`date +%s`
    which whois > /dev/null 2> /dev/null
    if [ $? -ne 0 ]
    then
        yum install -y whois
    fi
    
    which bc > /dev/null 2> /dev/null
    if [ $? -ne 0 ]
    then
        yum install -y bc
    fi
    cat domain.txt |while read line
    do
        domain_date=`whois ${line} |grep "Registry Expiry Date" |awk '{print $4}' |cut -d 'T' -f 1`
        domain_time=`date -d "${domain_date}" +%s`
        n=`echo "86400*7|bc"`
        domain_time1=$[$domain_time - $n]
        if [ $t1 -ge $domain_time1 ] && [ $t1 -lt $domain_time ]
        thenecho "$1 域名在 $domain_date 到期,请及时处理。" |mail -s "$1 域名到期通知" aming_test@163.com
        fi
    done

     == day 13参考答案 ==

    #!/bin/bash
    t1=`date +%s`
    is_install_whois()
    {
        which whois >/dev/null 2>/dev/null
        if [ $? -ne 0 ]
        then
            yum install -y jwhois
        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
            /usr/local/sbin/mail2.py aming_test@163.com "Domain $1 will be expire." "Domain $1 expire date is $e_d."
        fi
    }
    is_install_whois
    notify aminglinux.com
  • 相关阅读:
    Mybatis分页插件
    Mybatis代码自动生成
    Spring-Mybatis依赖
    Spring-test单元测试
    Spring-json依赖
    Spring-MVC依赖
    Log4j日志依赖
    Spring数据库连接池依赖
    Spring-JDBC依赖
    Spring依赖
  • 原文地址:https://www.cnblogs.com/ivan-yang/p/8342705.html
Copyright © 2011-2022 走看看