Certbot auto renew SSL/TLS certificate with a cron job

Jan 19, 2022 · 1 min read · Post a comment

If you are using a free SSL/TLS certificate from Certbot, probably you are tired of the manual renewal. Here I’m going to show you how to automate the process of creating a cron job that will automatically renew the expired certificates.


  • Certbot
  • Debian-based distro


Step 1. Navigate to the /etc/cron.d directory.

cd /etc/cron.d/

Step 2. Create a new file called certbot.

touch certbot

Step 3. Open the Certbot file and paste the following config:


0 0 * * * /usr/bin/certbot renew && systemctl restart nginx

Note: Confirm the Certbot binary path by running which certbot. Mostly, Certbot could be found under: /usr/bin/certbot or /usr/local/bin/certbot.

Step 4. Restart the cron service.

systemctl restart cron


Now, this cron job will check if some certificates are expired it will renew it automatically. In the next topic you will see how to renew it on RHEL-based distros. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.