How to use the command cronic (with examples)

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 by cronic. 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.

Related Posts

How to use the command compose (with examples)

How to use the command compose (with examples)

The compose command is an alias for the run-mailcap action “compose”.

Read More
How to use the command 'apg' (with examples)

How to use the command 'apg' (with examples)

The ‘apg’ command is a tool for generating random passwords. It provides various options to customize the generated passwords, such as password length, inclusion of symbols, numbers, and case sensitivity.

Read More
How to use the command chroma (with examples)

How to use the command chroma (with examples)

Chroma is a general-purpose syntax highlighter command. It is designed to automatically determine the syntax highlighting based on the file extension.

Read More