Huu Phan | Blog Linux operating system | Linux operating system -Blog Huu Phan | www.huuphan.com

This Blog is protected by DMCA.com

huuphan.com. Powered by Blogger.

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> [ ... ]

post new :

Huu Phan | Blog Linux operating system | Huu Phan ~ Zimbra Mail Server,linux,bash script,centos,linux command | www.huuphan.com