Skip to content

Instantly share code, notes, and snippets.

@ajaegers
Last active December 2, 2021 23:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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="debug@example.com"
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"
@MaryamMahmoodi
Copy link

thanks for your post I have question: how I change this "sudo certbot certonly --noninteractive --post-hook "service nginx reload" for Certbot Auto-renew on Multiple Domains?

@electropolis
Copy link

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

Should it be renew ?

@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