本文最后更新于15 天前,其中的信息可能已经过时,如有错误请发送邮件到big_fw@foxmail.com
1.监控方案
- 方式一:命令行curl的方式监控.
- 方式二:命令行命令监控
2.一个简单的监控脚本(使用culr命令)
#/bin/bash
#author:jing
#desc:检查证书过期时间
#1,vars
export LANG=en_US.UTF-8
#监控的域名+端口
URL='https://blog.chunxiai.top'
#过期时间,原始格式
date_expire=`curl -Lv $URL -o /dev/null |& grep 'expire date:'|awk -F 'date:|GMT' '{print $2}'`
#当前时间
date_now_sec=`date +%s`
#过去日期转换
date_expire_sec=`date +%s -d "$date_expire"`
#还有多少天过期
date_guoqi=`echo "($date_expire_sec - $date_now_sec)/60/60/24"|bc`
#进行判断
if [ $date_guoqi -le 300 ];then
echo "$URL ssl证书还有$date_guoqi天"
fi
3.使用命令的方式
“`bash
root@backup-248:/root/# openssl x509 -in /data/proxy/cert/scripts/letsencrypt/archive/blog.chunxiai.top/fullchain1.pem -noout -dates
notBefore=May 22 02:41:33 2025 GMT
notAfter=Aug 20 02:41:32 2025 GMT

