Skip to main content
2 of 2
added 184 characters in body
grrfield
  • 11
  • 1
  • 5

monitor log files and take actions upon a certain entry

i want to do the following:

tail -f some file { if newline matches/contains

somestring ( perform action1; perform action2; ...; more actions)

somestring2 ( perform other actions) ...

somestring999 (perform even another action) }

This is the closest i got for now:

tail -f /mnt/zandrologs/* | awk '/GRRFIELD/ { system("echo "test"") }'

but this will only recognise one parameter and it will only execute one command. I will need to have it recognising multiple patterns and executing multiple commands. Eventually i put this just in some bash script

Maybe this is not just the way to continue, but this is where i got just now. now it just reads the logs until it finds a string and outputs some garbage to teh console (test). I want to extend it, but i limited the question to the essence of what I want to do.

Thanks for helping me out with some basic syntaxis.

grrfield
  • 11
  • 1
  • 5