Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
inotifywait file watching handler
#!/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