How to use the command cronic (with examples)
The command cronic
is a bash script used to wrap cron jobs and prevent excess email sending. It can be used to call a command and display its output only if the command returns a non-zero exit code. This helps to reduce the amount of email notifications sent from cron jobs.
Use case 1: Call a command and display its output if it returns a non-zero exit code
Code:
cronic command
Motivation: When running cron jobs, it’s common for certain commands to fail occasionally. However, receiving an email notification for every failed command can quickly clutter the inbox. By using cronic
to wrap the command, email notifications will only be sent when the command returns a non-zero exit code. This helps to keep the inbox clean and focused on important notifications.
Explanation:
cronic
: The command to wrap another command and prevent excess email sending.command
: The command to be executed and wrapped bycronic
. This can be any valid shell command or script.
Example output:
Command output: (if command returns non-zero exit code)
<output of the command>
or
No output: (if command returns zero exit code)
Conclusion:
The cronic
command is a useful tool for preventing excess email sending from cron jobs. By wrapping commands with cronic
, email notifications will only be sent if the command returns a non-zero exit code. This helps to declutter the inbox and focus on important notifications.