Automatic Renewal of certifications: what's the correct procedure?

These two commands need to be on their own. (And usually certbot is run as root, but I don't know your setup so you may not need privilege elevation.)

marco@pc01:~$ sudo certbot renew
marco@pc01:~$ sudo logrotate -f certbot

If they must be on the same line, e.g. for cron, you can use the && construct (or a semicolon if you want the logs to rotate whether or not certbot successfully renews your certs) to run them on the same line.

marco@pc01:~$ sudo certbot renew && sudo logrotate -f certbot

Your cron job isn't running because Ubuntu uses systemd as its init system. (Take a peek at the comments in /etc/cron.d/certbot.) Also, there isn't a root command available for Ubuntu (did a quick search on the Ubuntu Packages site and I can't see anything that provides a root executable).

You'll have to manually create the cron job yourself by using sudo cron and entering in something like:

0 */12 * * * sleep $(awk 'BEGIN{;srand();print int(1+rand()*30);}')m;certbot renew && logrotate -f certbot

(The above must be entered into root's crontab!)

1 Like