certbot の cron 設定を systemd-timer 設定へ変更する手順です.なお,利用している OS は fedora 35(2022/4/19現在)です.
certbot をインストールするとタイマー用のファイル /usr/lib/systemd/system/certbot-renew.timer もインストールされるので,以下のコマンドで有効にします.
systemctl enable --now certbot-renew.timer
つづいて,/etc/sysconfig/certbot の以下の行を,
POST_HOOK=""
次のように変更します.
POST_HOOK="--post-hook 'systemctl restart httpd'"
systemctl list-timers を実行して,次のように次回実行時刻が表示されていれば設定完了です.
NEXT LEFT LAST PASSED UNIT ACTIVATES
(途中略)
Sun 2022-04-03 05:21:26 JST 14h left Sat 2022-04-02 13:10:58 JST 2h 4min ago certbot-renew.timer certbot-renew.service
(途中略)
11 timers listed.
Pass --all to see loaded but inactive timers, too.
最後に cron から certbot ジョブを削除します.
参考までに certbot-renew.timer と certbot-renew.service の内容を以下に示します.(certbot インストール時のままです)
# cat /usr/lib/systemd/system/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
# cat /usr/lib/systemd/system/certbot-renew.service
[Unit]
Description=This service automatically renews any certbot certificates found
[Service]
EnvironmentFile=/etc/sysconfig/certbot
Type=oneshot
ExecStart=/usr/bin/certbot renew --noninteractive --no-random-sleep-on-renew $PRE_HOOK $POST_HOOK $RENEW_HOOK $DEPLOY_HOOK $CERTBOT_ARGS
コメント