There are a few easy ways to check when an SSL certificate expires. Write Your Own Shell Script Here's a simple script that checks the expiration date of an SSL certificate: #!/bin/sh TARGET=$1 if [ -z "$TARGET" ]; then echo "Provide a host as a parameter" exit 1 fi echo "Checking $TARGET..." expirationdate=$(openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \ | openssl x509 -text \ | grep 'Not After' \ | awk '{print $4,$5,$7}') if [ -z "$expirationdate" ]; then echo "Failed to retrieve certificate expiration date for $TARGET" exit 1 fi echo "Certificate expires on $expirationdate" #!/bin/sh TARGET=$1 if [ -z "$TARGET" ]; then echo "Provide a host as a parameter" exit 1 fi echo "Checking $TARGET..." expirationdate=$(openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \ | openssl x509 -text \ | grep 'Not After' \ | awk '{print $4,$5,$7}') if [ -z "$expirationdate" ]; then echo "Failed to retrieve certificate expiration date for $TARGET" exit 1 fi echo "Certificate expires on $expirationdate" Usage: Usage: Save the script as ssl.sh ssl.sh Make it executable: sudo chmod +x ssl.sh sudo chmod +x ssl.sh Run it: ./ssl.sh example.com ./ssl.sh example.com Use a Prebuilt Script You can also use a ready-made tool like ssl-cert-check for more features. ssl-cert-check Get Notified with a Telegram Bot Want to automate monitoring and get notified before a certificate expires? Use Telegram Bot that can monitor and notify you about TLS/SSL certificate expiration Telegram Bot that can monitor and notify you about TLS/SSL certificate expiration