Skip to content

Instantly share code, notes, and snippets.

@icecreammatt
Created September 11, 2015 06:17
Show Gist options
  • Save icecreammatt/e9b9cf973a4a1212b8a7 to your computer and use it in GitHub Desktop.
Save icecreammatt/e9b9cf973a4a1212b8a7 to your computer and use it in GitHub Desktop.
Monitor log and call function when output matches pattern
#!/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