Answer the question
In order to leave comments, you need to log in
How to subtract dates with different timezones in sh?
you need to follow the date of the certificate on the site. ( openssl will not work because the certificate still needs to be validly applied and not just present)
curl -sIv https://letsencrypt.ks03.ru |& grep "expire date:" | sed -e 's/\(.*\)expire date: //g'
date
Answer the question
In order to leave comments, you need to log in
Convert the output to the desired format and compare.
$ TZ=GMT date
Пт авг 30 12:13:14 GMT 2019
$ LC_ALL=C TZ=GMT date +%Y%m%d%H%M%S
20190830121541
$ LC_ALL=C TZ=GMT date --date="Nov 28 09:32:50 2019 GMT" +%Y%m%d%H%M%S
20191128093250
$EXPIRE=`curl -sIv https://letsencrypt.ks03.ru |& grep "expire date:" | sed -e 's/\(.*\)expire`
$ALERT_DATE=`date -I --date "$EXPIRE - 10 days"`
$NOW_DATE=`date -I`
expr "$ALERT_DATE" \< "$NOW_DATE" > /dev/null && notify
-I
prints the date without time in ISO format compared as a string but according to the local time zone, --date
universally eats various strange expressions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question