Pipelineing works in cron just as well as in bash. You could pipe the output to a script, that examines it and sends the mail. Or even easier use grep:
# in /etc/crontab
[email protected]
SHELL=/bin/bash
# m h dom mon dow user command
30 * * * * confus /home/confus/bin/someCommand.sh | grep -A 11 -B 10 "Error:"
This will send an e-mail to [email protected] when the stirng "Error: " occures in the output of someCommand.sh
. In this case the text of the e-mail will be the output from 10 lines before and 11 lines after the occurrence of "Error: " (hence the -A
for after and -B
for before).
The mail is only send if the computer running cron has a working mail-server installed. A script to process the output is of course more flexible and considerably more work.