#!/bin/bash
date=`echo \
|openssl s_client -servername $1 -connect "$1":443 2>/dev/null \
| openssl x509 -noout -enddate \
| awk -F"=" '{print $2}'\
|awk '{print $4"-"$1"-"$2}'\
|awk '{gsub(/Jan/,"01")}1' \
|awk '{gsub(/Feb/,"02")}1' \
|awk '{gsub(/Mar/,"03")}1' \
|awk '{gsub(/Apr/,"04")}1' \
|awk '{gsub(/May/,"05")}1' \
|awk '{gsub(/Jun/,"06")}1' \
|awk '{gsub(/Jul/,"07")}1' \
|awk '{gsub(/Aug/,"08")}1' \
|awk '{gsub(/Sep/,"09")}1' \
|awk '{gsub(/Oct/,"10")}1' \
|awk '{gsub(/Nov/,"11")}1' \
|awk '{gsub(/Dec/,"12")}1' `

endDate=`date -d $date +%s`
startDate=`date +%s`
stampDiff=`expr $endDate - $startDate`
dayDiff=`expr $stampDiff / 86400`
echo $dayDiff

echo 'hello world' | mail -s "Subject" -t  506079@qq.com,506079@qq.com    -a From:506079@qq.com