我从pip3安装了certbot:
# pip3 freeze|grep -i certbot
certbot==1.5.0
certbot-apache==1.5.0
certbot-dns-digitalocean==1.5.0我可以以root身份从命令行运行certbot,但我将crontab配置为每周运行两次perl -e 'sleep int(rand(1800))' && certbot -q renew,并通过电子邮件获得以下错误消息:
/bin/sh: 1: certbot: not found如果我在命令行输入whereis certbot,就会得到以下结果:
certbot: /usr/local/bin/certbot为什么certbot不能从crontab成功运行?
我在用Ubuntu 18.04。
发布于 2020-06-18 14:19:27
您需要在crontab中使用填充路径,而您的可执行文件不属于cron的路径,默认情况下,路径只包括/bin和/usr/bin。所以你的职位看起来应该是:
* * * * * perl -e 'sleep int(rand(1800))' && /usr/local/bin/certbot -q renew您可以自定义cron的环境,如最后一点这里所示,但IMO最好将脚本(和cron作业)更改为与默认环境一起工作,这样,在设置新系统时,它们将更加可移植。
发布于 2021-03-16 20:47:13
TL:对于Ubuntu20.04用户来说,不要忘记certbot是与管理单元一起安装的。
这个答案和问题使我走上了正确的道路。在Ubuntu20.04中,certbot完成器管理单元。我安装时遵循了一个教程,但是忘记了所有关于snap的事情。@Uri的whereat certbot帮助我注意到位置发生了变化。要么跑
0 2**1 /snap/bin/certbot更新
或者在PATH环境变量中包含snap
SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/snap/bin
https://certbot.eff.org/lets-encrypt/ubuntufocal-apache
*突出重点

https://askubuntu.com/questions/1251568
复制相似问题