Skip to content

Instantly share code, notes, and snippets.

@pgassmann
Last active May 18, 2016 08:50
Show Gist options
  • Save pgassmann/bd7b59ae54c95b8a24f8834cb72f4651 to your computer and use it in GitHub Desktop.
Save pgassmann/bd7b59ae54c95b8a24f8834cb72f4651 to your computer and use it in GitHub Desktop.
Get number of days till certificate file expires in bash
#!/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