Uri*_*Uri 2 command-line bash cron 18.04
我从 pip3 安装了 certbot:
# pip3 freeze|grep -i certbot
certbot==1.5.0
certbot-apache==1.5.0
certbot-dns-digitalocean==1.5.0
Run Code Online (Sandbox Code Playgroud)
我可以以 root 身份从命令行运行 certbot,但我将 crontab 配置perl -e 'sleep int(rand(1800))' && certbot -q renew为每周以 root身份运行两次,并通过电子邮件收到此错误消息:
/bin/sh: 1: certbot: not found
Run Code Online (Sandbox Code Playgroud)
如果我whereis certbot在命令行输入,我会得到这个结果:
certbot: /usr/local/bin/certbot
Run Code Online (Sandbox Code Playgroud)
为什么 certbot 不能从 crontab 成功运行?
我正在使用 Ubuntu 18.04。
您需要在其中使用填充路径,crontab而您的可执行文件不属于 cron 的 PATH,默认情况下仅包含/bin和/usr/bin. 所以你的 cronjob 应该是这样的:
* * * * * perl -e 'sleep int(rand(1800))' && /usr/local/bin/certbot -q renew
Run Code Online (Sandbox Code Playgroud)
你可以自定义的cron的环境,因为它是在最后点出在这里,但国际海事组织是更好地改变你的脚本(和cronjobs)工作与既定的环境,因此,他们会更加便于携带,当你安装一个新的系统, 等等。
| 归档时间: |
|
| 查看次数: |
729 次 |
| 最近记录: |