全球主机交流论坛
标题:
inotify+rsync懂得进
[打印本页]
作者:
Apian
时间:
2019-8-21 00:05
标题:
inotify+rsync懂得进
本帖最后由 Apian 于 2019-8-21 00:07 编辑
inotify+rsync遇到了个问题:
一旦当文件发生变化同步后,就隔一段时间(大概一分钟不到)就自动轮询一次文件夹,造成了服务器的负载。。。
/usr/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src|while read files
do
/usr/bin/rsync -avzP --delete --progress ${src} ${user}@${host1}::${dst} --password-file=/etc/web.passwd
echo "${file} was rsyncd"
done
复制代码
如果只是启动这个脚本,暂时没有文件变化的时候,就不会隔一段时间轮询一次。。。
这个是什么问题?到底要怎么弄?
难道你是监测到文件变化后去同步完成就好了么?为啥还要隔一段时间轮询一次目录啊
sent 16,559,294 bytes received 9,062 bytes 241,873.81 bytes/sec
total size is 654,649,017,020 speedup is 39,512.01
was rsyncd
sending incremental file list
sent 16,559,302 bytes received 9,070 bytes 241,874.04 bytes/sec
total size is 654,649,017,020 speedup is 39,511.97
was rsyncd
sending incremental file list
sent 16,559,306 bytes received 9,074 bytes 241,874.16 bytes/sec
total size is 654,649,017,020 speedup is 39,511.95
was rsyncd
sending incremental file list
sent 16,559,298 bytes received 9,066 bytes 241,873.93 bytes/sec
total size is 654,649,017,020 speedup is 39,511.99
was rsyncd
sending incremental file list
sent 16,559,290 bytes received 9,058 bytes 241,873.69 bytes/sec
total size is 654,649,017,020 speedup is 39,512.03
was rsyncd
sending incremental file list
sent 16,559,302 bytes received 9,070 bytes 241,874.04 bytes/sec
total size is 654,649,017,020 speedup is 39,511.97
was rsyncd
sending incremental file list
sent 16,559,218 bytes received 8,986 bytes 238,391.42 bytes/sec
total size is 654,649,017,020 speedup is 39,512.37
was rsyncd
sending incremental file list
复制代码
作者:
xcy1020
时间:
2019-8-21 00:16
用lsyncd
作者:
醉里耍大刀
时间:
2019-8-21 00:16
文件数量多的时候,用这个就不靠谱了,非常消耗资源,可以做主动同步
作者:
why?
时间:
2019-8-21 12:56
实时性不高的话建议定时任务,或者试试lsyncd
欢迎光临 全球主机交流论坛 (https://loc.isir333.eu.org/)
Powered by Discuz! X3.4