Raync + Inotify Synchronous Practice

Source: Internet
Author: User

Premise: Rsync can push and pull normally

1. Download Inotify-tools

: https://cloud.github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz

# RPM-QA gcc-c++ gcc #检查是否安装编译工具

Gcc-c++-4.4.7-3.el6.x86_64

Gcc-4.4.7-3.el6.x86_64

#yum install make GCC gcc-c++ #如果没有, installing the Build tool

# Tar XF inotify-tools-3.14.tar.gz #解压文件

# CD inotify-tools-3.14 #进入到解压目录

#./configure--prefix=/usr/local/inotify #配置

#make && make install #编译安装

#echo $? #检查是否安装成功 0 indicates successful installation

0


INotify Common parameters


-r|--recursive Watch directories recursively.

-q|--quiet print less (only print events)

-m|--monitor Keep listening for events forever.

-e|--event

Accessfile or directory contents were read

Modifyfile or directory contents were written

attribfile or directory attributes changed

Close_writefile or directory closed, after being opened in

writeable Mode

Close_nowritefile or directory closed, after being opened in

read-only Mode

Closefile or directory closed, regardless of read/write mode

Openfile or directory opened

Moved_tofile or directory moved to watched directory

Moved_fromfile or directory moved from watched directory

Movefile or directory moved to or from watched directory

Createfile or directory created within watched directory

Deletefile or directory deleted within watched directory

Delete_selffile or directory was deleted

UnmountFile system containing file or directory unmounted

Test Script 1:

#!/bin/bash####/usr/local/inotify/bin/inotifywait-mrq--timefmt '%d/%m/%y%h:%m '--format '%T%w%f '-e close_write,  delete,create,attrib/backup/| While read file, do cd/backup/&& rsync-az-r--delete./[Email protected]::d ata1--password-file =/etc/rsync.password >/dev/null 2>&1 doneexit 0

Test Script 2:

#!/bin/bash####/usr/local/inotify/bin/inotifywait-mrq-e Close_write,delete,create,attrib/backup | While read Rsync-az--delete $line [email protected]::d ata1--password-file=/etc/rsync.password &G T;/dev/null 2>&1 Doneexit 0

Reference: http://www.osyunwei.com/archives/7435.html

Https://github.com/rvoicilas/inotify-tools/wiki#getting

This article is from the "Daniel" blog, so be sure to keep this source http://2143754.blog.51cto.com/2133754/1775293

Raync + Inotify Synchronous Practice

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.