Looking for good programming challenges?

Use the search below to find our solutions for selected questions!

Cronjob to renew Let’s Encrypt Certificate

Sharing is caring!

In this post I have described how to manually renew Let’s Encrypt SSL certificate. Here I describe how to configure a cronjob to automatically renew my certificates when they are about to expire.

Setup default AMI editor to nano:

Add the following:

The && operator makes sure the commands are run sequentially.

The --quiet flag is to silence all output except errors. Since certificates are only renewed when they’re determined to be near expiry, the command can run on a regular basis, like every week or every day). That is why you want to use the -q or --quiet quiet flag to silence all output except errors.

This cron job will run twice a day, it will check if your will expire in less than 30 days, if it doesn’ it will do nothing, if it will expire in less than 30 days it will try to issue a new cert using the same paramaters as the first time you issued your cert.

Scheduling Tasks with Cron Jobs