Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autorenewal not working. #8

Closed
dewzor opened this issue Apr 30, 2018 · 6 comments
Closed

Autorenewal not working. #8

dewzor opened this issue Apr 30, 2018 · 6 comments

Comments

@dewzor
Copy link

dewzor commented Apr 30, 2018

Thanks for this awesome script!

Only one problem, and its a big one. Autorenewal is not working as it should. I use this script on 5 sites and ive found three of them unable to auto renew. So when i visit the site i suddenly get SSL warning etc. This is absolutely terrible for the sites rankings.

I would be very grateful if you could fix this as this is an awesome script, simple to use. When i manually run rwssl, it renews without any issue at all.

@oadslug
Copy link

oadslug commented May 1, 2018

I’m experiencing the same issue. I suspect the problem might have something to do with the cron task not being run from the correct environment, perhaps. For example, I notice that if I run the same command manually while logged in as root, it renews correctly. But when run from cron (saved in the root cron file), I get the following error (via email).

/bin/sh: 1: sudo service nginx-sp stop && yes | letsencrypt --standalone renew &>/dev/null && service nginx-sp start && service nginx-sp reload: not found

Unfortuanately, I don’t know exactly how to resolve this, as my understanding of shell environments is pretty limited. Any help would be much appreciated.

And btw, thank you for the script! Other than this issue, it’s a life saver. I suspect the answer is probably quite simple.

@wikrie
Copy link

wikrie commented May 7, 2018

If somebody found an answer could you please update:
https://askubuntu.com/questions/1033316/letsencrypt-auto-renew-cronjob-failing

@oadslug
Copy link

oadslug commented May 8, 2018

After some testing, I've made some progress:

  1. The crontab should be run using 'bash' (not the default 'sh'), because:
    &>/dev/null is bash syntax ('sh' would be >/dev/null 2>&1)
    • sh does not recognize commands in quotation marks (produces 'not found' error).
  2. The crontab should define the default PATH variables.
  3. If the crontab is run under root, then don't need to use 'sudo' (although probably doesn't hurt).

To edit the root crontask, use sudo crontab -e -u root

My final crontab file looks like this:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
  
@monthly service nginx-sp stop && yes | letsencrypt --standalone renew &>/dev/null && service nginx-sp start && service nginx-sp reload
#

I'll test this more and see if it's a full fix, and report back.

Note: In terms of fixing the original script, might want to wrap the command in a bash subshell to make sure it gets run in bash (from Ubunto SE):

bash -c "bashcommand"

@rehmatworks
Copy link
Owner

Thanks for the input from all. I've upgraded the script and now it should be working fine as well as it is much more user-friendly now. Please reclone the script and you will be able to do much more with great ease.

@alexcroox
Copy link

If I'm on an older version (not sure how to check which) from earlier this year. How do I update and install the required cron job fixes? (Mine fails to auto renew currently)

@rehmatworks
Copy link
Owner

rehmatworks commented Oct 2, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants