检测域名有效期的 Shell 脚本
2008-03-14 23:34
1156 查看
在我的 Wiki 上阅读该文:
http://maclife.net/wiki/index.php?title=%E6%A3%80%E6%B5%8B%E5%9F%9F%E5%90%8D%E6%9C%89%E6%95%88%E6%9C%9F%E7%9A%84_Shell_%E8%84%9A%E6%9C%AC
检测域名有效期的 Shell 脚本
2007-11-10
闲来无事,写了个检测域名有效期的小脚本,检测完毕后将结果通过邮件发送,在 Cygwin 下测试通过 linux 下未测试,linux 下需要安装 email 邮件发送工具,email 工具可以从 http://email.cleancode.org 下载,当然你也可以改用其他邮件发送工具
if (window.showTocToggle) { var tocShowText = "显示"; var tocHideText = "隐藏"; showTocToggle(); }
在与脚本相同的路径下创建 domain-names.txt 文件,并在里面输入你感兴趣的域名,每个域名占 1 行,域名前面加 # 的域名则不会被检测
把该脚本加入到 cron 定时任务或 Windows 任务计划中,使其定期执行
http://maclife.net/wiki/index.php?title=%E6%A3%80%E6%B5%8B%E5%9F%9F%E5%90%8D%E6%9C%89%E6%95%88%E6%9C%9F%E7%9A%84_Shell_%E8%84%9A%E6%9C%AC
检测域名有效期的 Shell 脚本
2007-11-10
闲来无事,写了个检测域名有效期的小脚本,检测完毕后将结果通过邮件发送,在 Cygwin 下测试通过 linux 下未测试,linux 下需要安装 email 邮件发送工具,email 工具可以从 http://email.cleancode.org 下载,当然你也可以改用其他邮件发送工具
目录[隐藏]1 使用方法 2 代码 Code 3 domain-names.txt 样例 4 又见 |
使用方法
将脚本中的邮件地址改为自己的邮件地址,将脚本保存到 $HOME/cron 路径下(其他路径也可以,但要修改脚本中的相应的路径)在与脚本相同的路径下创建 domain-names.txt 文件,并在里面输入你感兴趣的域名,每个域名占 1 行,域名前面加 # 的域名则不会被检测
把该脚本加入到 cron 定时任务或 Windows 任务计划中,使其定期执行
代码 Code
#!/bin/bash cd $HOME/cron for domain in `tac domain-names.txt` do if [[ "${domain:0:1}" != "#" ]]; then # 域名前面带 # 的则忽略 domainWhoisInfo=`whois ${domain}` expirationDate=`echo "${domainWhoisInfo}" | grep --max-count=1 "Expiration Date:"` expirationDate="${expirationDate/Expiration Date: /}" expirationDate=`date --date="${expirationDate}" "+%F %H:%M"` expirationDate="${expirationDate/00:00/}" # 国际域名不包含时间 beginDate_Second=`date +%s` endDate_Second=`date --date="${expirationDate}" +%s` remainDays=`expr /( $endDate_Second - $beginDate_Second /) / 86400` echo "${domainWhoisInfo}" | email --from-name "domain check" --subject "${domain}: ${expirationDate}, 还剩 ${remainDays} 天" YOUR_EMAIL_ADDRESS@mail-provider.com fi done
domain-names.txt 样例
microsoft.com # #google.cn google.com sourceforge.net maclife.net #...
又见
http://bbs.chinaunix.net/thread-1013882-1-1.html相关文章推荐
- shell检测interface是否已分配ip,qt调用shell脚本
- Shell脚本写一个快速简单的检测局指定域网内有多少台服务器
- shell脚本检测网络是否畅通
- [Shell脚本工具]-01批量检测服务器接口状态码
- 检测CPU利用率的Shell脚本
- SHELL脚本中取得域名的IP地址
- shell脚本---mysql检测监控脚本系列
- 检测网段IP使用情况的shell脚本
- [shell]通过ping检测整个网段IP的网络状态脚本
- 案例:Shell脚本检测网站url是否正常运行
- VGA GPU passthrough qemu虚拟桌面pci穿透--Shell脚本检测与关机
- 通过shell脚本检测MySQL服务信息
- shell脚本---回文检测
- shell脚本――爬取域名一级页面元素并判断其可缓存性
- 通过shell批量检测集群跑数据是否异常脚本
- shell脚本检测数据库AB复制
- 检测tomcat运行状态,自动重启TOMCAT脚本SHELL
- shell脚本——检测SSL证书过期时间