Sphere
Log in Join
☆ 8

Let's Encrypt renews fine by hand but fails from cron

certbot 2.10 on Debian 12, nginx plugin. Running the renew command as root works and renews the cert. The same command from a cron job leaves an error about the nginx configuration directory. I assume it is an environment difference, but which variable actually matters here?

⚑ Report

4 replies

☆ 3
J Jonas ·2026-11-05#1

Cron gives you a minimal PATH and no HOME worth mentioning. certbot uses HOME for its config and logs, and calls nginx from PATH. Put an absolute path to certbot and nginx in the crontab and set PATH explicitly.

⚑ Report
☆ 0
R Ravi ·2026-11-08#2

That got me further. Now it says it cannot find the nginx binary when it tries the authenticator.

⚑ Report
☆ 0
B Bruno ·2026-11-10#3

Add PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin at the top of the crontab, and use certbot --nginx --config /etc/letsencrypt/renewal.conf. Better yet, use the systemd timer that ships with the package; it already has the right environment.

⚑ Report
☆ 0
R Ravi ·2026-11-12#4

Enabled certbot.timer and disabled my cron line. The dry run under the timer passed.

⚑ Report
Log in to reply.