Example of inotify. Sh script

Source: Internet
Author: User
Tags inotify
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

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.