前面已经看了不少样本,下面看看配置文件
inotify 相关的几个系统参数
/proc/sys/fs/inotify/max_user_instances 初始化 ifd 的数量限制
/proc/sys/fs/inotify/max_queued_events ifd 文件队列长度限制
/proc/sys/fs/inotify/max_user_watches 注册监听目录的数量限制
文件描述符,受 /etc/security/limits.conf 和 /proc/sys/fs/file-max 限制
默认值:
/proc/sys/fs/inotify/max_user_instances 16384
/proc/sys/fs/inotify/max_queued_events 128
/proc/sys/fs/inotify/max_user_watches 65536
/proc/sys/fs/file-max 6815744
#!/bin/bash
inotify_rsync_fun ()
{
dir=`echo $1 | awk -F"," '{print $1}'`
ip=`echo $1 | awk -F"," '{print $2}'`
des=`echo $1 | awk -F"," '{print $3}'`
user=`echo $1 | awk -F"," '{print $4}'`
/home/test/inotify/bin/inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' -e modify,delete,create,attrib ${dir} |while read DATE TIME DIR FILE
do
FILECHAGE=${DIR}${FILE}
/usr/bin/rsync -av --progress --delete --password-file=/home/test/rsync.passwd ${dir} ${user}@${ip}::${des} && echo "At ${TIME} on ${DATE}, file $FILECHAGE was backed up via rsync" >> /home/test/rsyncd.log
done
}
count=6
# localdir,host,rsync_module,user of rsync_module,
sync1="/home/test1/rsync/ ,192.168.1.166,test1,root"
sync2="/home/test2/rsync/ ,192.168.1.166,test1,root"
sync3="/home/test1/rsync/ ,192.168.1.165,test1,root"
sync4="/home/test2/rsync/ ,192.168.1.165,test2,root"
sync5="/home/test1/rsync/ ,192.168.1.164,test2,root"
sync6="/home/test2/rsync/ ,192.168.1.164,test2,root"
#############################################################
#main
i=0
while [ ${i} -lt ${count} ]
do
i=`expr ${i} + 1`
tmp="sync"$i
eval "sync=\$$tmp"
inotify_rsync_fun "$sync" &
done