首页 > 解决方案 > 让 certbot 等待另一个实例

问题描述

我在这里尝试做的是:我有一个由计时器控制的 systemd 服务,该计时器处理letsencrypt证书的更新。配置文件中规定了这些证书的外观。

[Unit]
Description=Let's Encrypt renewal

[Service]
Type=oneshot
Environment=CONFIG_FILE=/etc/letsencrypt/test.conf
ExecStart=-/usr/bin/certbot renew --quiet --agree-tos --noninteractive --no-random-sleep-on-renew

续订会运行一些后处理脚本,以确保部署和安装证书。

如果配置要在证书生成和上次续订之间更改,这些脚本将找不到预期名称下的证书。然后脚本会自动触发另一个脚本,确保创建了证书:

if [[ ! -d /etc/letsencrypt/live/${CERT_NAME} ]]
then
  #certificate folder we expect isn't there , request a new cert
  . /etc/letsencrypt/renewal-hooks/request-new-cert.sh
fi

我遇到的问题是,在 request-new-cert.sh 执行期间,我收到一个错误Another Instance of Certbot is already running,导致脚本失败。

我要解决这个问题了吗?有没有更好的方法来尝试实现我想要做的事情?

标签: bashcertificatesystemdlets-encryptcertbot

解决方案


解决方案1:

您需要杀死其他 certbot 进程。您可以通过重新启动盒子或终止特定进程来做到这一点。要查找 certbot 进程,请尝试:

ps -ef | grep certb

进程 ID 将是用户之后的第一个数字,例如:

root 5555 5100 …

要终止该进程,请尝试:

kill 5555

注意:将 5555 替换为您的实际 certbot PID#

解决方案2:

如果它没有运行,请检查您的系统中是否有 .certbot.lock 文件。

find / -type f -name ".certbot.lock"

如果有,您可以删除它们:

find / -type f -name ".certbot.lock" -exec rm {} \;

然后再试一次。


推荐阅读