Your crontab entry looks fine, with one possible exception: certbot should probably have a full path specification. For example:
0 22 * * * /path/to/certbot .....
If that doesn't resolve the issue, we'll need more information. I suspect the issue is the environment, but we'll need to ask cron what environment has been created for the root user. We can phrase our question as follows:
- Create a shell script in your home directory (
~/) as follows (or with the editor of your choice):
$ nano ~/envtst.sh
- Enter the following in the editor, after adjusting for your system/user:
#!/bin/sh
/bin/echo "env report follows for user "$USER >> /home/you/envtst.sh.out
/usr/bin/env >> /home/you/envtst.sh.out
/bin/echo "env report for user "$USER" concluded" >> /home/you/envtst.sh.out
/bin/echo " " >> /home/you/envtst.sh.out
- Save the file, exit the editor and set file permissions as executable.
$ chmod a+rx ~/envtst.sh
- Run the script you just created, and review the output in
/home/you/envtst.sh.out. This output will show your current environment as the $USER you're logged in as:
$ ./envtst.sh $$ cat /home/you/envtst.sh.out
- Open your
crontab for editing:
$ crontab -e -u root
- Enter the following line at the bottom of your
crontab:
* * * * * /home/you/envtst.sh >> /home/you/envtst.sh.err 2>&1
The output file /home/you/envtst.sh.out will contain a listing of the environment for the "root cron user". Once you know that, adjust your crontab entry for certbot accordingly. Post the output here if questions remain.
Cron generally requires that commands are terminated with a new line. Edit your crontab; go to the end of the line which contains the last command and insert a new line (press enter). - in addition to using an absolute path as Seamus remarked
– HBruijn Apr 04 '19 at 05:38