Skip to content

Instantly share code, notes, and snippets.

@ajaegers
Last active December 2, 2021 23:11
Show Gist options
  • Save ajaegers/92318bdc81541b825c90f265f787e3c8 to your computer and use it in GitHub Desktop.
Save ajaegers/92318bdc81541b825c90f265f787e3c8 to your computer and use it in GitHub Desktop.
Simple Certbot (Let's Encrypt) script for auto-renewal certificates
# Put this file in folder /etc/cron.d/
MAILTO="[email protected]"
0 1 * * * root /usr/local/sbin/certbot-renew.sh
#!/bin/bash
#
# Supposing you have /etc/letsencrypt/cli.ini config file with domains
#
# Put this script in a daily cron and your cert will be automagically updated 30 days before expiration.
# If renew doesn't succeed, you'll receive email notification from your CA.
#
# https://certbot.eff.org/docs/using.html#renewal
#
sudo certbot-auto renew --noninteractive --post-hook "service apache2 reload"
@ajaegers
Copy link
Author

sudo certbot certonly --noninteractive --post-hook "service apache2 reload"

Should it be renew ?

Yes renew is better, and using certbot-auto to stay up to date too.
Thanks for your reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment