INotify Monitoring folder status under Linux, triggering rsync synchronization after changes have occurred

Source: Internet
Author: User

1. Installation Tools
--inotify
wget http://cloud.github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
TAR-ZXVF inotify-tools-3.14.tar.gz
CD inotify-tools-3.14
./configure--prefix=/usr/local/inotify
Make && make install

--rsync
Download: http://rsync.samba.org/
TAR-ZXVF rsync-3.1.0.tar.gz
CD rsync-3.1.0
./configure--prefix=/usr/local/rsync
Make && make install

2. Write Scripts:
[Email protected] script]$ vim monitor_dircharge.sh
#!/bin/sh
## -------------------------------------------------

# # @ Monitor directory status, change to trigger rsync sync
## -------------------------------------------------

Srcdir= "/data/www/new/html/www"
/usr/bin/inotifywait-mrq--timefmt '%d/%m/%y-%h:%m '--format '%t%w%f '-e modify,delete,create,attrib ${srcdir} \
| While read file
Do
sudo rsync-rlptdvzhs--port=9789--password-file=/etc/rsyncd.password_client/data/www/new/html/www/[email protected]::server/new/html/www/
Done

3. Startup script
Nohup sudo sh/data/script/monitor_dircharge.sh >>/tmp/inotify.log 2>&1 &

INotify Monitoring folder status under Linux, triggering rsync synchronization after changes have occurred

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.