Check whether a certificate expires within the next days
check if certificate expires in 30 days | monitor ssl expiry with cron | openssl checkend script | certificate expiration warning script | openssl | certificate | expiry | monitoringopenssl x509 -in /etc/letsencrypt/live/example.com/cert.pem -noout -checkend $(( 30 * 86400 )) && echo "noch gültig" || echo "läuft bald ab"The -checkend option expects seconds and returns exit code 0 if the certificate is still valid after that time, otherwise 1. The $(( ... )) arithmetic converts days into seconds. This makes it easy to trigger a warning in scripts or cron jobs before visitors see an error message.
Note: Root is only needed for protected paths like /etc/letsencrypt/.
Also searched as
- check if certificate expires in 30 days
- monitor ssl expiry with cron
- openssl checkend script
- certificate expiration warning script