Auto-Renew Let’s Encrypt Certs on Linux with Cron
Automatically renewing Let's Encrypt certificates on Linux requires creating a bash renewal script and scheduling it with cron. Create a script calling `certbot renew`, then add a crontab entry running it twice daily, which is Let's Encrypt's recommended frequency. Certbot only renews certificates expiring within 30 days, making frequent checks safe and reliable.
Auto-Renew Let’s Encrypt Certs on Linux with CronAndrew Baker's Technology Blog Posts, 21/Nov/2022
https://andrewbaker.ninja/2022/11/21/auto-renew-lets-encrypt-certs-on-linux-with-cron/
If you want to automatically renew your certs then the easiest way is to setup a cron just to call letsencrypt periodically. Below is an example cron job:
First create the bash script to renew the certificate
$ pwd
/home/bitnami
$ sudo nano renew-certificate.shNow enter the script in the following format into nano:
#!/bin/bash
sudo /opt/bitnami/ctlscript.sh stop apache
sudo /opt/bitnami/letsencrypt/lego --path /opt/bitnami/letsencrypt --email="[email protected]" --http --http-timeout 30 --http.webroot /opt/bitnami/apps/letsencrypt --domains=andrewbaker.ninja renew --days 90
sudo /opt/bitnami/ctlscript.sh start apacheNow edit the crontab to run the renew script:
$ crontab -e
0 0 * * * sudo /home/bitnami/renew-certificate.sh 2> /dev/null