monitor adding/updating/removing files by inotify

yum install inotify-tools
inotifywait -e create,delete,modify,move -mrq /etc &

or simple bash:

#!/bin/sh

/usr/bin/inotifywait -e create,delete,modify,move \
-mrq /etc | while read line; do
echo -n “$line ” >> /var/log/inotify.log
echo `date | cut -d ” ” -f1-4` >> /var/log/inotify.log
done

Leave a Reply

Your email address will not be published. Required fields are marked *