Skip to content

Instantly share code, notes, and snippets.

@dan-rally
Last active October 26, 2020 09:29
Show Gist options
  • Select an option

  • Save dan-rally/ea30fae87ea609b411acca3e60bd2e40 to your computer and use it in GitHub Desktop.

Select an option

Save dan-rally/ea30fae87ea609b411acca3e60bd2e40 to your computer and use it in GitHub Desktop.
Renew Let's Encrypt with Systemd (Nginx)

Using systemd timers for Let's Encrypt renewal on Nginx

Both files needs to be added to:

/etc/systemd/system/

To start the timer:

$ sudo systemctl start certbot-renew.timer

To enable the timer to be started on boot-up:

$ sudo systemctl enable certbot-renew.timer

To show status information for the timer:

$ systemctl status certbot-renew.timer

To show journal entries for the timer:

$ journalctl -u certbot-renew.service

Credit: https://stevenwestmoreland.com/2017/11/renewing-certbot-certificates-using-a-systemd-timer.html.

[Unit]
Description=Certbot Renew
[Service]
ExecStart=/usr/bin/certbot renew --pre-hook "systemctl stop nginx.service" --post-hook "systemctl start nginx.service"
[Unit]
Description=Certbot Renew Timer
[Timer]
OnBootSec=300
OnUnitActiveSec=1w
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment