Created
October 9, 2012 10:38
-
-
Save ysugimoto/3857887 to your computer and use it in GitHub Desktop.
inotifywait file watching handler
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 | |
# kill already process | |
PROC=`pgrep -f inotifywait` | |
if [ -n "${PROC}" ]; then | |
echo $PROC | xargs kill | |
fi | |
/usr/bin/inotifywait -e create,modify -mrq /home/my.file | while read line; do | |
path=`echo $line | /bin/awk '{print $1$3}'` | |
echo $path | some program | |
done & # daemon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment