Monday, May 6, 2024
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 1854  / 2 Years ago, wed, june 8, 2022, 8:15:40

I installed certbot from pip3:


# pip3 freeze|grep -i certbot
certbot==1.5.0
certbot-apache==1.5.0
certbot-dns-digitalocean==1.5.0

I can run certbot from the command line as root, but I configured crontab to run perl -e 'sleep int(rand(1800))' && certbot -q renew as root twice a week, and I get this error message by email:


/bin/sh: 1: certbot: not found

If I type whereis certbot at the command line I get this result:


certbot: /usr/local/bin/certbot

Why doesn't certbot run from crontab successfully?


I'm using Ubuntu 18.04.


More From » command-line

 Answers
2

You need to use fill paths within crontab while your executable doesn't belong to the cron's PATH, which by default includes only /bin and /usr/bin. So your cronjob should look like:


* * * * * perl -e 'sleep int(rand(1800))' && /usr/local/bin/certbot -q renew

You could customize the cron's environment as it is shown at the last point here, but IMO it is better to change your scripts (and cronjobs) to work with the default environment, thus they will be more portable, when you are setup a new system, etc.


[#3176] Friday, June 10, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ndaavi

Total Points: 169
Total Questions: 116
Total Answers: 113

Location: Falkland Islands
Member since Wed, Dec 23, 2020
3 Years ago
;