Last active
January 14, 2021 09:22
-
-
Save Pandry/3826f712ef1b49934ed9fccb4102fe9c to your computer and use it in GitHub Desktop.
Automatic certbot autorenewal via systemd's timer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat<<EOF>/etc/systemd/system/certbot-renew.service | |
[Unit] | |
Description=Renew Let's Encrypt certificates service | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/bin/certbot renew --post-hook "/usr/bin/systemctl reload nginx" --quiet | |
#ExecStart=/usr/bin/certbot renew --standalone --pre-hook "/usr/bin/systemctl stop nginx" --post-hook "/usr/bin/systemctl start nginx" --quiet | |
EOF | |
cat<<EOF>/etc/systemd/system/certbot-renew.timer | |
[Unit] | |
Description=Renew Let's Encrypt certificates timer | |
[Timer] | |
#Every year, month and day at 18 and 4 | |
OnCalendar=*-*-* 04,18:36:28 | |
Persistent=true | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
systemctl enable certbot-renew.timer | |
systemctl start certbot-renew.timer | |
# To check: | |
# systemctl list-timers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment