“Cronic” is a bash script that serves as a wrapper for cron jobs to prevent excessive email notifications. When cron jobs are executed, any output or error messages generated by the job are typically sent via email to the user or administrator who owns the cron job. However, for some jobs that run frequently or generate a lot of output, this can result in a flood of email notifications, making it difficult to identify important information.
To address this issue, “cronic” provides a solution by suppressing unnecessary email notifications while still capturing any important error messages. It allows administrators to receive email notifications only when there are actual errors or issues with the execution of the cron job.
Here’s how “cronic” works:
- Capturing Output: When a cron job is executed, “cronic” captures the standard output (stdout) and standard error (stderr) generated by the job. Instead of sending this output directly via email, “cronic” redirects it to temporary files for further processing.
- Filtering Output: “cronic” analyzes the captured output and applies filters to determine if any error messages or relevant information exist. It looks for patterns that indicate errors, such as specific keywords or error codes. If such patterns are found, “cronic” considers them as significant and proceeds to send an email notification.
- Suppressing Non-Error Output: If the captured output does not contain any significant error messages, “cronic” suppresses the email notification, preventing excessive email sending. This helps reduce email clutter and ensures that only important error information is delivered via email.
- Email Notification: In case “cronic” detects errors or relevant information in the captured output, it composes an email notification and sends it to the relevant user or administrator. The email typically includes the captured output, allowing them to review the error details and take necessary action.
By using “cronic” to wrap cron jobs, administrators can effectively manage and control the flow of email notifications, ensuring that they receive important information while avoiding email overload caused by non-critical job output.
To use “cronic,” it needs to be installed and properly configured on the system running the cron jobs. The specific configuration steps may vary depending on the operating system and cron implementation being used.
It’s worth noting that “cronic” is a widely used script, but it is not a standard part of cron or the Bash shell. Therefore, it may need to be installed separately or obtained from trusted sources before it can be utilized.
cronic Command Examples
1. Call a command and display its output if it returns a non-zero exit code:
# cronic command
Summary
Overall, “cronic” provides a useful solution for managing cron job output and preventing excessive email notifications, allowing administrators to focus on critical error messages and take appropriate action when necessary.