Skip to content

Instantly share code, notes, and snippets.

@djch
Last active November 1, 2017 03:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djch/f9a52fe30093d417b687 to your computer and use it in GitHub Desktop.
Save djch/f9a52fe30093d417b687 to your computer and use it in GitHub Desktop.
Monitor a log for a thing which triggers another thing
#!/bin/sh
#
# You can start the script on boot, in the background, by adding it to /etc/rc.local:
# echo -e "/path/to/logmon.sh &\n" >> /etc/rc.local
#
tail -Fn0 /path/to/that/logfile.log | \
while read line ; do
echo "$line" | grep "thing"
if [ $? = 0 ]
then
/bin/trigger-sumthin
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment