Cron output as information [solved]

I have my cron setup to email me on the event an error with one of my jobs occurs and this works pretty well in general.

However when certbot does not have to renew my certificate I get the following sent to my email:
Cert not yet due for renewal

Is there a way to change this output to the regular log instead of the error log since this is just information and no actual problem with the execution of the script? I still want to receive actual errors in my mailbox though.

Thanks in advance!

Hello @dannyvanderzande,

You can use the --quiet parameter to silence all output but errors:

-q, --quiet           Silence all output except errors. Useful for
                        automation via cron. Implies --non-interactive.
                        (default: False)

The problem using --quiet is that you won’t receive a mail when your certs are renewed so I use this to silence all the output but errors and when the certs are renewed.

/path/to/certbot-auto renew --quiet --renew-hook 'echo "\nI have renewed the cert located on ${RENEWED_LINEAGE} and this cert contains the following domains ${RENEWED_DOMAINS}\n\n" >&2' --post-hook 'service apache2 reload'

1.- You should change certbot-auto by certbot or whatever is the name of certbot client on your machine.
2.- Variable ${RENEWED_LINEAGE} will point to the config live subdirectory containing the new certs and keys.
3.- Variable ${RENEWED_DOMAINS} will contain a space-delimited list of renewed cert domains.
4.- The trick is redirect stdout to stderr with >&2 on echo command so you will be notified in successful renewals.
5.- You can use --post-hook to reload/restart your services, in this example I’m reloading apache so change it to fit your needs.

The mail that you will receive will have this look:

Error output from None:

I have renewed the cert located on /etc/letsencrypt/live/yourdomain.tld and this cert contains the following domains yourdomain.tld example1.yourdomain.tld example2.yourdomain.tld otherdomain.tld

Hope this helps.


1 Like

Hi @sahsanu,

Thanks a lot for the info. I really didn’t know about those options. I have just updated my cron job and I’m testing it right now. Execution of the job is set to every 12 hours so I’ll report back in a few days on how things went.

1 Like


The problem seems to be solved right now. I only received an email once telling me my certs were updated (good timing).

Thanks a lot!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.