Search code examples
bashshellcroncentos

Alerting on a failed cron job


Is there anyway to alert on a cron job that may have failed to execute for whatever reason on a CentOS 7 EC2 instance? I'm looking for a tool or to review a process that anyone else might be using for something like this.


Solution

  • There is a good answer to your question here: https://unix.stackexchange.com/questions/314640/how-to-make-cron-send-email-with-error-log-when-script-throws-errors

    In summary it says:

    20 6-10 * * 1-5 ~/job_failure_test.sh > ~/job_fail.log 2>&1 || mail -s "Errors" [email protected] < ~/job_fail.log
    

    But follow the link to the question as there is some good pointers there.