Skip to content

Instantly share code, notes, and snippets.

@etowett
Last active September 20, 2017 10:11
Show Gist options
  • Save etowett/a7fef041f4604a84be552be4258ddec0 to your computer and use it in GitHub Desktop.
Save etowett/a7fef041f4604a84be552be4258ddec0 to your computer and use it in GitHub Desktop.
-----------------------------------------------
/etc/systemd/system/renew-letsencrypt.service :
-----------------------------------------------
[Unit]
Description=Renew Let's Encrypt certificates
[Service]
Type=oneshot
# check for renewal, only start/stop nginx if certs need to be renewed
ExecStart=/opt/letsencrypt/certbot-auto renew --standalone --pre-hook "/bin/systemctl stop nginx" --post-hook "/bin/systemctl start nginx"
---------------------------------------------
/etc/systemd/system/renew-letsencrypt.timer :
---------------------------------------------
[Unit]
Description=Daily renewal of Let's Encrypt's certificates
[Timer]
# once a day, at 2AM
OnCalendar=*-*-* 02:00:00
# Be kind to the Let's Encrypt servers: add a random delay of 0–3600 seconds
RandomizedDelaySec=3600
Persistent=true
[Install]
WantedBy=timers.target
==========================================================================
sudo systemctl daemon-reload
sudo systemctl start renew-letsencrypt.timer
sudo systemctl enable renew-letsencrypt.timer
- start and enable the timer
sudo systemctl list-timers
sudo journalctl -u renew-letsencrypt
sudo journalctl -u renew-letsencrypt --since="yesterday"
- You can verify that the timer has been started, its planned execution times, service logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment