Skip to content
Advertisement

Tail a log file on linux and trigger a script if words are matched

I’m looking for a way to watch multiple logfiles on linux and look for words or phrases inside and if found, trigger a script or action, this will need to be constant.

I know this can be done with some grep, tail hack but I want to know if there is something premade for this with config options, for instance, I think logtail can monitor files but can’t trigger actions.

Any ideas?

Advertisement

Answer

The answer is SEC (yum install sec). What it does is that it monitors any log file and uses rules to scan the files using regex and then you can run shell scripts, insert logs, and some other stuff.

It runs as a service so no problem with machine reboots, crons, etc.

Hope this helps anybody trying to do what I wanted.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement