Example of inotify. Sh script
[[Email protected] ~] # Cat/Server/scripts/inotify. Sh
#! /Bin/bash
# Para
Host01 = 192.168.1.111
Src =/Dingjian
DST = Dingjian
User = rsync_backup
Rsync_passfile =/etc/rsync. Password
Intify_home =/usr/local/inotify-tools-3.14/
# Judge
If [! -E "$ SRC"] \
| [! -E "$ {rsync_passfile}"] \
| [! -E "$ {inotify_home}/bin/inotifywait"] \
| [! -E "/usr/bin/rsync"];
Then
Echo "check file and folder"
Exit 9
Fi
$ {Inotify_home}/bin/inotifywait-mrq -- timefmt '% d/% m/% Y % H: % m' -- format' % T % w % F'-e close_write, delete, create, attrib $ SRC \
| While Read File
Do
# Rsync-avzp -- delete -- timeout = 100 -- password-file =$ {rsync_passfile} $ SRC [email protected] $ host01 ::$ DST>/dev/null 2> & 1
CD $ SRC & rsync-Aruz-r -- Delete. /-- timeout = 100 [email protected] $ host01: $ DST -- password-file =$ {rsync_passfile}>/dev/null 2> & 1
Done
Exit 0
Example of inotify. Sh script