Certbot example: standalone

From wikinotes

If you aren't running a webserver, you can use the certbot standalone renewal. It will spin up it's own webserver just for the cert renewal.

Documentation

official docs https://certbot.eff.org/docs/using.html#standalone

Setup

Generate Certificate

certbot --standalone certonly \
    --domain yourdomain.com \
    --agree-tos \
    --no-eff-email

Cron job to rewnew SSL certificate (every 2 months, within 1hr of 6am)

0 6 1 */2 *  /usr/bin/bash -c 'sleep $[RANDOM\%60]m' && /usr/bin/certbot renew --agree-tos --no-eff-email