📄shell判断ssl证书过期时间
2023-4-4
| 2023-4-10
0  |  0 分钟
type
status
date
slug
summary
tags
category
icon
password
参考脚本
cat check_ssldate.sh #!/bin/bash array=(www.qq.com) Time_left(){ #过期时间 time_GMT=$1 # GMT时间转为时间戳 timestamp_get=$(date -d "${time_GMT}" +%s) #当前时间 curtime_GMT=$(date -u '+%b %d %T %Y GMT') timestamp_cur=$(date -d "${curtime_GMT}" +%s) #时间戳的差,单位秒 left_s=`expr "${timestamp_get}" - "${timestamp_cur}"` left_day=`awk 'BEGIN{printf "%0.0f","'${left_s}'"/3600/24}'` } main(){ #将$1转换为新的arr,不能直接使用常规的$1 newarr=($@) echo "本次检查域名列表:"${newarr[@]} echo "###########check start###########" for dm in ${newarr[@]};do out=`echo | openssl s_client -servername $dm -connect $dm:443 2>/dev/null | openssl x509 -noout -dates 2>/dev/null|sed ":a;N;s/\n/ /g;ta"` expired=`echo $out|awk -F= '{print $NF}'` Time_left "${expired}" [[ -n "$out" ]]&&echo -n $dm "," $out&&echo " ,剩余天数:" ${left_day} [[ -z "$out" ]]&&echo $dm "," "empty" done echo "###########check stop###########" } #测试 main ${array[@]}
技术
  • scripts
  • 阿里云terraform记录date获取GMT时间差
    目录