Chinaunix首页 | 论坛 | 博客
  • 博客访问: 522215
  • 博文数量: 81
  • 博客积分: 8020
  • 博客等级: 中将
  • 技术积分: 1085
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-08 10:36
文章分类

全部博文(81)

文章存档

2010年(3)

2009年(25)

2008年(53)

我的朋友

分类:

2008-03-25 15:59:22

#!/bin/sh

basedir="/home/wwwroot/"
inotifywait -mq --timefmt '%d/%m/%y %H:%M' --format '%T %w' \
 -e close_write --fromfile filecheck | while read date time file; do
    project=`echo ${file} | sed -e 's/\/home\/wwwroot\///' -e 's/\/abc//'`
    cd ${basedir}
    for host in `cat /tmp/${project}`; do
    rsync -aRz --delete ${file#${basedir}} ${host}::rsynctest/ && \
    echo "At ${time} on ${date}, project ${project} was updated to ${host}"
    done
done

变量project为网站项目,对应虚拟主机DocumentRoot,同时也指定该项目包含的所有主机。
filecheck为每个项目对应触发同步的文件,通过检测该文件中定义检测的文件名的变化来触发对应的同步。


注意:inotify在gentoo上的最新版本是3.12,这个版本有bug,需要自己下载安装3.13。

其它linux操作系统也可以下载3.13并安装。
下载地址:

阅读(1359) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~