Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
inotifywait file watching handler
# kill already process
PROC=`pgrep -f inotifywait`
if [ -n "${PROC}" ]; then
echo $PROC | xargs kill
/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