Events on Log analyse
Hello ! I'm French so sorry if my English isn't the best.
I would like to have a shell script making events analysing my logs in /var/log/ For example, by running tail -f /var/log/apache/access.log - I would like, for each GET requests, to run a command like /usr/bin/beep to make simple. Thank you in advance !! |
Save the follow shell script as beep.sh, then run:
chmod +x beep.sh Then run: tail -f /var/log/apache/access.log | beep.sh GET The argument to beep.sh is the string you want to match on. So if you wanted to look for HEAD requests instead of GET, run it like this: tail -f /var/log/apache/access.log | beep.sh HEAD Or for a particular IP address: tail -f /var/log/apache/access.log | beep.sh "192.168.0.123" ... You get the idea. Also, your English is quite good ;) Code:
#!/bin/sh |
Thanks a lot !
It works verry fine. |
All times are GMT -5. The time now is 08:30 PM. |