[Solved] Automatically restarting nginx upon cert renewal

Hi folks,

My crontab is set up, so that letsencrypt renew gets executed bi-daily, and does its job.

The only thing not automated is reloading nginx. I could simply add yet another crontab entry for it but I rather wouldn’t. Every server restart is a potential opportunity for things to go wrong, so I’d like to reload nginx only when at least one cert gets renewed.

Waiting for your ultimate wisdom.

Laci

--post-hook "service nginx restart" is probably what you’re looking for.

  --post-hook POST_HOOK
                        Command to be run in a shell after attempting to
                        obtain/renew certificates. Can be used to deploy
                        renewed certificates, or to restart any servers that
                        were stopped by --pre-hook. This is only run if an
                        attempt was made to obtain/renew a certificate.
                        (default: None)
1 Like

Thank you so much! This is exactly what I’ve been looking for. I’ll use

--post-hook "service nginx reload"

since reload is safer than restart.

2 Likes

So finally what does your full crontab line look like? Are you able to share. Thank you.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.