Created
September 11, 2015 06:17
-
-
Save icecreammatt/e9b9cf973a4a1212b8a7 to your computer and use it in GitHub Desktop.
Monitor log and call function when output matches pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
tail -fn0 /var/log/file.log | while read line ; do | |
echo "$line" | grep "pattern" | |
if [ $? = 0 ] | |
then | |
echo "Log: $line" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment