Last active
May 18, 2016 08:50
-
-
Save pgassmann/bd7b59ae54c95b8a24f8834cb72f4651 to your computer and use it in GitHub Desktop.
Get number of days till certificate file expires in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get number of days till certificate file expires in bash | |
# calculate number of days between two dates in bash | |
A="now" | |
B="$(openssl x509 -in /path_to_cert.pem -noout -enddate | cut -d= -f2-)" | |
echo "( `date -d \"$B\" +%s` - `date -d \"$A\" +%s`) / (24*3600)" | bc -l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment