A cure for Crons chronic email problem

A cure for Crons chronic email problem

Crontab’s constant emails can be pain, but when things go wrong its the quickest way to know. This tool takes care of the all pointless email and only sends you important ones.

Anyone who has setup a backup system on their Linux machine, and I hope you all have, will be well aware of the problems when running commands from crontab. You will be inundated with emails every-time cron runs and with so many emails its easy to get to a point where you just stop reading them so never notice that Friday night when the backups stopped due to some error and from that point on they never ran correctly again.

One solution most of us will be familiar with is simple to direct all command output to /dev/null 15 01 * * * backup_my_pc >/dev/null 2>&1 but this now mean we want get any feedback - whether the backup ran correctly or not!

After a little time spent with Google I found a program called Chronic. It acts as a wrapper script within the cron shell. So now instead of having 15 01 * * * backup_my_pc as your crontab command you use 15 01 * * * cronic backup_my_pc. Cronic will then run your shell command so it can handle all output from your command. If the command fails the full output is printed to the shell, so cron sends it as an email, but if no error occurs all output is hidden and no email is sent. A perfect solution.


The best way to install Cronic is simply to download the shell script from the project website. Copy the download into your PATH, usually /usr/bin will be fine. Then just start updating your crontab rules.

© 2020. Some rights reserved. The contents of this site is released under a Creative Commons Attribution-Share Alike license.