I have a log file that occasionally has critical errors. Each time a critical error occurs, I'd like to have an email sent to myself notifying me of the change. Is there a unix tool / set of unix tools I can adapt for this purpose?
What I thought of doing was
tail -f logfile | grep CRITICAL > critical.errors
watch tail critical.errors # And somehow, email on changes.
However, the watch command doesn't take an action. So ... is there something like 'watch' that does. Or perhaps a good existing script that will do this? I can homebrew a bash/python solution, but I'd rather reuse existing tools for cleaner error handling, etc.