LetsEncrypt サーバ証明書を自動更新する


これはなに

サーバ証明書を自動更新するようにした際のメモ。

1. certbot-auto 版

1-1. 更新バッチ

/root/certbot/certbot-auto が置いてある前提。

/root/certbot/renew.sh
#!/bin/bash
/root/certbot/certbot-auto renew --post-hook "systemctl restart nginx"
mail -s "`hostname` executed certbot-auto renew, status: $?" <to-mail_address> < /dev/null

1-2. crontab

毎週月曜 5:01 に実行。

1 5 * * 1 /root/certbot/renew.sh >/dev/null 2>&1

2. certbot 版

2-1. 更新バッチ

/root/letsencrypt/renew.sh
#!/bin/bash
certbot renew --post-hook "systemctl restart nginx"
mail -s "`hostname` executed certbot renew, status: $?" <to-mail_address> < /dev/null

2-2. crontab

1 5 * * 1 /root/letsencrypt/renew.sh >/dev/null 2>&1