inotify.sh脚本(inotify+rsync)

来源:互联网 发布:淘宝发布宝贝照片尺寸 编辑:程序博客网 时间:2024/05/20 03:45

uname -r

ls /porc/sys/fs/inotify/

wget  -O /etc/yum.repos.d/epel.repo http:mirrors.aliyun.com/repo/epel-6.repo

yum -y install inotify-tools

inotifywait -mrq --timefmt '%d%m%y %H%M' --format '%T%f' -e close_write,delete /data


以下是脚本内容

vim /server/script/inotify.sh

#!/bin/bash
/usr/bin/inotifywait -mrq --timefmt '%d%m%y %H%M' --format '%T%f' -e close_write,delete /data \
| while read file
  do
    cd /data&&\
    rsync -az ./ --delete rsync_backup@172.16.1.41::backup/ --password-file=/etc/rsync.password
  done


####end####

执行

sh inotify.sh

0 0