I want to check when week left before the certificate expires for our users on Openvpn server. On server installed Centos 6.7. I can export enddate and subject from all .crt to txt file with the commandopenssl x509 -subject -enddate -noout -in filenamein format:subject= /C=Country/ST=ca/L=City/O=company/OU=uit/CN=user/emailAddress=emailnotAfter=Oct  8 13:48:27 2020 GMTCurrent date on server in format - Wed May 25 10:03:06 MSK 2016How to compare current date and date in line notAfter in txt file, and if left week or less before the certificate expires, make the txt file with name of user from the subject line with text True?
How to compare current date and date from line in txt file?
bash
The easiest way is to convert the date string to epoch time, which is counted in seconds since 1970-01-01 00:00:00 UTC, and compare the number of seconds.To get the current date in seconds, do:[jenny@finch ~]$ date +%s1464162079To get the date from the date string above, do[jenny@finch ~]$ date -d 'Oct 8 13:48:27 2020 GMT'  +%s1602164907A week is 604800 seconds, so check whether the difference between the two times is less than that.