To install inotify-tools on centos
sudo yum install inotify-toolsTo install inotify-tools on ubuntu
sudo apt-get install inotify-toolsFor example, how to monitor folder /home/huupv with action create,delete,modiy,move. The scripts as below:
#!/bin/bash
#Author huupv
#My blog huuphan.com
inotifywait -m -r /home/huupv -e create -e delete -e modify -e move |
while read FOLDER ACTION1 ACTION2 ACTION3 ACTION4
do
echo "Path $FOLDER Create $ACTION1" >>/tmp/output
echo "Path $FOLDER Delete $ACTION2" >>/tmp/output
echo "Path $FOLDER Modify $ACTION3" >>/tmp/output
echo "Path $FOLDER Move $ACTION4" >>/tmp/output
done
The man page inotifywait
man inotifywaitNAME
inotifywait - wait for changes to files using inotify
SYNOPSIS
inotifywait [-hcmrq] [-e <event> ] [-t <seconds> ] [--format <fmt> ]
[--timefmt <fmt> ] <file> [ ... ]
Thanks for reading use inotify-tools on centos My blog Effortless Zimbra Mail Management: Unleashing the Power of Linux Commands, How-To, and Bash Scripts I hope this is useful.