-1

Using CentOS 8 I want to add a cron which shall execute below command after every month

sudo certbot renew --non-interactive

Can someone please assist how actually I can do it using Linux shell.

kenlukas
  • 2,886
  • 2
  • 14
  • 25
  • Please read the certbot documentation. It contains the cron settings you need. It also explains why it should be run daily, not monthly. – Gerald Schneider Apr 22 '20 at 08:28
  • 1
    Does this answer your question? [Cron job for let's encrypt renewal](https://serverfault.com/questions/790772/cron-job-for-lets-encrypt-renewal) – Gerald Schneider Apr 22 '20 at 08:49

1 Answers1

2

Having just set this up myself recently, I found the documentation for getting up and running with certbot to be excellent (https://certbot.eff.org/lets-encrypt/centosrhel8-nginx). Their specific recommendation is to run the following command:

echo "0 0,12 * * * root python3 -c 'import random; import time; time.sleep(random.random() * 3600)' && /usr/local/bin/certbot-auto renew -q" | sudo tee -a /etc/crontab > /dev/null

This will run the command /usr/local/bin/certbot-auto renew -q at 00:00 and 12:00 every day after sleeping for a random number of seconds between 0 and 3600. The injection of the random number of seconds is to stop their servers being overloaded on the exact hour/minute when crons are setup. I would go with their recommendation because the more frequent the check, the less likely you are to be hit by random connectivity issues. Please note, it only updates the certificate if it needs to.

  • I am beginner to linux, can you please confirm below I have accessed "crontab -e" and inserted this line 0 0 * * * sudo certbot renew --non-interactive Save file and exist Do you think this is it and this cron will execute daily at midnight ? – Tahir 1234 Apr 22 '20 at 17:38
  • @Tahir1234 sorry for the delay in getting back to you. Yes that would to the trick. Documentation is available here http://man7.org/linux/man-pages/man5/crontab.5.html . Or to be really sure, check your schedule with https://crontab.guru/ – Ben Dalling Apr 23 '20 at 18:15