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
  • 相关阅读:
    将现有MySQL数据库改为大小写不敏感
    在Windows中玩转Docker Toolbox
    使用ABP EntityFramework连接MySQL数据库
    数据库设计范式2——BC范式和第四范式
    让OData和NHibernate结合进行动态查询
    文档在线预览的实现
    有哪些老鸟程序员知道而新手不知道的小技巧?自我感受
    EEPROM的概念接口类型及软件实例
    flash的几种模式Normal Mode、DUAL Mode、Quad Mode的概念和区别
    ESP8266 打造一款物联网产品---搭建环境编译及烧录
  • 原文地址:https://www.cnblogs.com/ivan-yang/p/8342705.html
Copyright © 2011-2022 走看看