If you want certbot-auto
to reload nginx after issuing or renewing a certificate, you may want to use --deploy-hook
. But if you put the plain service nginx reload
there, it may actually fail to renew, and you would get the following error in your /var/log/letsencrypt/letsencrypt.log
:
deploy-hook command "service nginx reload" returned error code 127 Error output from deploy-hook command: /bin/sh: 1: service: not found
This means that path to service
wasn't resolved - the shell environment is aware of fewer paths/locations compared to your user environment. So if the command is recognised when you type it in the terminal, that doesn't mean the shell or cron will find it.
To solve the issue, simply provide the full path to the executable: --deploy-hook "/usr/sbin/service nginx reload"
.
You can find the full path to service
using which service
.
If you're in a script, SERVICE=$(which service)
sets the right path into variable ${SERVICE}
. You can then call --deploy-hook "${SERVICE} nginx reload"
.