Any failure notifications from cron?

Does busybox cron send any sort of notification or log output if a task exits non-zero? I'm running a backup script daily via cron, and I'd like some type of log or notification if it fails.

As a test I put "exit 1" at the end of my script, but I see no indication of failure in cron log files.

Thanks.

Cron actually put a error log line in the system log for every job it does with positive result to begin with. So what a failed job for cron would be I don’t know.

2 Likes

Check exit codes inside the backup script and send an error message to the logger:
https://openwrt.org/docs/guide-user/base-system/log.essentials

4 Likes

Nothing. Failed result codes cause no log message to be written (other than the notification that the command was run). I even checked running crond at the most verbose log level, and it still doesn't log anything extra for a failed command. It also logs nothing for a command which emits output to stdout or stderr (traditionally that output would be mailed to root)

Looks like that is the only way.

TBH I find this behaviour very annoying. I have cron jobs that run every few minutes, and this really litters in the syslog.

To get it to shut up, you have to run crond at log level 9, which basically turns off all crond logging entirely, even if it catches fire.

1 Like

You can run rsyslog instead and filter out the cron jobs to its own log file.

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.