How can I use the crontab run follow command every week?

certbot renew --pre-hook "systemctl stop nginx" --post-hook "sudo systemctl restart nginx"

What should add after type crontab -e?

1 Like

There are a lot of guides you could find on the world wide web explaining how cron works, such as

This issue/question is also barely certbot related, so please check out the guide above. I'm fairly certain it contains enough info to get it working.

That said, usually certbot is ran twice a day: it will only renew certs due for renewal anyway, if properly configured.


I had thought that most installations of certbot created their own scheduled task (through cron or systemd or whatever), and used the last successfully-run hooks automatically for it. So you might not need to type anything.


Automated Renewals

Many Linux distributions provide automated renewal when you use the packages installed through their system package manager.


If you are not sure whether or not your system has this already automated, refer to your distribution’s documentation, or check your system’s crontab (typically in /etc/crontab/ and /etc/cron.*/* and systemd timers ( systemctl list-timers ).

If you give more details about how you installed certbot and your platform, someone might be able to help you check if there's already a renewal task made for you.


I don't see why you would stop one functional web service to start another and then stop it to restart the first one (just to get a cert).

And unless all your certs are using --standalone, this method may not fit all (future) cases.

So, I would recommend that you review the other authentication methods and see if any can work with your current web service.


I imagine one guy running an entire airport who changes his hat and jacket every time he walks to a station with a different role... :laughing:

Quite right. That was my exact thought. :face_with_monocle:

1 Like

If I don't stop ngnix first, it will showing:

Problem binding to port 80: Could not bind to IPv4 or IPv6.. Skipping.

1 Like

That's correct. Why not just use --nginx instead of --standalone (and skip stopping nginx altogether)?

1 Like

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