Certbot更新cronのエラーを確認/修正する方法

Certbot更新cronのエラーを確認/修正する方法

終日TLSゾーンのバグを修正することに集中しましたが、この質問は特にTLSに関するものではありません。

さて、私はそれぞれ独自のSSL証明書を持つ複数のWebサイトを持つWebサーバーを持っています。

しかし、これまで私は次のようにDebian 9.2にCertbotバージョン0.19.0を正常にインストールしました。

  1. ソースにバックポートを追加します。

    deb http://ftp.debian.org/debian stretch-backports main
    
  2. バックポートから最新バージョンのCertbotをインストールします。

    apt-get install python-certbot-apache -t stretch-backports
    

その後、更新ファイルにいくつかの主要な調整を行う必要があるため、次のようになりました。

# renew_before_expiry = 30 days
version = 0.10.2
archive_dir = /etc/letsencrypt/archive/pavelstriz.cz-0001
cert = /etc/letsencrypt/live/pavelstriz.cz-0001/cert.pem
privkey = /etc/letsencrypt/live/pavelstriz.cz-0001/privkey.pem
chain = /etc/letsencrypt/live/pavelstriz.cz-0001/chain.pem
fullchain = /etc/letsencrypt/live/pavelstriz.cz-0001/fullchain.pem

# Options used in the renewal process
[renewalparams]
authenticator = webroot
installer = apache
rsa_key_size = 4096
account = c3f3d026995c1d7370e4d8201c3c11a2
must_staple = True

[[webroot_map]]
pavelstriz.cz = /home/pavelstriz/public_html
www.pavelstriz.cz = /home/pavelstriz/public_html

pavelstriz.czその後、ドメイン名を正常に更新しました。

certbot renew --dry-run

しかし、私が心配するのは毎日Certbot cronです。

# /etc/cron.d/certbot: crontab entries for the certbot package
#
# Upstream recommends attempting renewal twice a day
#
# Eventually, this will be an opportunity to validate certificates
# haven't been revoked, etc.  Renewal will only occur if expiration
# is within 30 days.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew

実際に動作するかどうか、正常に実行する方法がわかりません。

私が実行した場合:

/usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew

Bashでは、次のように言います。

Saving debug log to /var/log/letsencrypt/letsencrypt.log
The requested ! plugin does not appear to be installed

私はコマンドを間違って理解したかもしれません。

ベストアンサー1

cronが実行する実際のコマンドは次のとおりです。

test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew

まず、いくつかのファイルをテストしてみてください。

test -x /usr/bin/certbot -a \! -d /run/systemd/system

翻訳したもの

  • 存在し、/usr/bin/certbot実行可能です(-x /usr/bin/certbot)。
  • いいえ(-a \!
  • /run/systemd/system存在し、ディレクトリ(-d /run/systemd/system)です。

テストが成功したら、ランダムな時間(perl -e 'sleep int(rand(3600))')を待ってから証明書の更新を試みます(certbot -q renew)。

しかし、systemdデフォルトでインストールされているDebian 9では、これが/run/systemd/system存在することを意味し、ディレクトリなので、初期テストは失敗し、updateコマンドは決して実行されません。

実際の更新は、ファイルで定義されているシステムタイマーによって管理されますlib/systemd/system/certbot.timer。バージョン0.27.0-1に基づいて内容は次のとおりです。

[Unit]
Description=Run certbot twice daily

[Timer]
OnCalendar=*-*-* 00,12:00:00
RandomizedDelaySec=43200
Persistent=true

[Install]
WantedBy=timers.target

cerbotが正しく設定されている場合は、おそらく次のような行を見つけることができます。

Nov  2 20:06:14 hostname systemd[1]: Starting Run certbot twice daily.
Nov  2 20:06:14 hostname systemd[1]: Started Run certbot twice daily.

あなたのsyslog

おすすめ記事