-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.

2

1 Answer 1

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.

2
  • 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, 2020 at 17:38
  • @Tahir1234 sorry for the delay in getting back to you. Yes that would to the trick. Documentation is available here man7.org/linux/man-pages/man5/crontab.5.html . Or to be really sure, check your schedule with crontab.guru Apr 23, 2020 at 18:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.