Just another IT site ※IT系の記事は当方環境での実施内容となるため実施する場合は自己責任でお願いいたします。At Your Own Risk!! TURN BACK WHILE YOU CAN
PR

Let’s Encryptの自動更新(systemd.timer)

※IT系の記事は当方環境での実施内容となるため実施する場合は自己責任でお願いいたします。スクリプトはAI生成のものも多いのでコピー&ペーストの際は文字コードに注意ください!

Let’s Encryptをインストールしたら、証明書の定期更新をCronに仕込むのがお作法かと思っていたが、今どきはcertbotインストール時に「systemd.timer」で更新がスケジュールされており、知らないうちに動いていた。。。実行ログをみてみたら、しっかり0時、12時に動いており、さらに消し忘れの設定も発見するという。。。

# cat /etc/systemd/system/timers.target.wants/certbot-renew.timer
[Unit]
Description=This is the timer to set the schedule for automated renewals

[Timer]
OnCalendar=*-*-* 00/12:00:00
RandomizedDelaySec=12hours
Persistent=true

[Install]
WantedBy=timers.target
# journalctl -u certbot-renew

Oct 03 02:12:07 xxxxxx systemd[1]: certbot-renew.service: Main process exited, code=exited, status=1/FAILURE
Oct 03 02:12:07 xxxxxx systemd[1]: certbot-renew.service: Failed with result 'exit-code'.
Oct 03 02:12:07 xxxxxx systemd[1]: Failed to start This service automatically renews any certbot certificates found.
Oct 03 13:30:12 xxxxxx systemd[1]: Starting This service automatically renews any certbot certificates found...
Oct 03 13:30:13 xxxxxx certbot[211299]: Saving debug log to /var/log/letsencrypt/letsencrypt.log
Oct 03 13:30:13 xxxxxx certbot[211299]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Oct 03 13:30:13 xxxxxx certbot[211299]: Processing /etc/letsencrypt/renewal/xxxxxx.conf
Oct 03 13:30:13 xxxxxx certbot[211299]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# certbot delete
Saving debug log to /var/log/letsencrypt/letsencrypt.log

Which certificate(s) would you like to delete?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: xxxxxx
2: xxxxxx
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 2

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The following certificate(s) are selected for deletion:

  * xxxxxx

WARNING: Before continuing, ensure that the listed certificates are not being
used by any installed server software (e.g. Apache, nginx, mail servers).
Deleting a certificate that is still being used will cause the server software
to stop working. See https://certbot.org/deleting-certs for information on
deleting certificates safely.

Are you sure you want to delete the above certificate(s)?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y
Deleted all files relating to certificate xxxxxx.

 

 

 

タイトルとURLをコピーしました