use inotify-tools on centos

inotifywait - wait for changes to files using inotify.

To install inotify-tools on centos
sudo yum install inotify-tools
To install inotify-tools on ubuntu
sudo apt-get install inotify-tools
For 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 inotifywait
NAME
       inotifywait - wait for changes to files using inotify

SYNOPSIS
       inotifywait  [-hcmrq]  [-e  <event> ] [-t <seconds> ] [--format <fmt> ]
       [--timefmt <fmt> ] <file> [ ... ]

Comments

Popular posts from this blog

zimbra some services are not running [Solve problem]

Bash script list all IP addresses connected to Server

How to install php7 on centos 6