全球主机交流论坛

标题: inotify+rsync懂得进 [打印本页]

作者: Apian    时间: 2019-8-21 00:05
标题: inotify+rsync懂得进
本帖最后由 Apian 于 2019-8-21 00:07 编辑

inotify+rsync遇到了个问题:
一旦当文件发生变化同步后,就隔一段时间(大概一分钟不到)就自动轮询一次文件夹,造成了服务器的负载。。。
  1. /usr/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src|while read files
  2. do
  3.   /usr/bin/rsync -avzP --delete --progress ${src} ${user}@${host1}::${dst} --password-file=/etc/web.passwd
  4.   echo "${file} was rsyncd"
  5. done
复制代码


如果只是启动这个脚本,暂时没有文件变化的时候,就不会隔一段时间轮询一次。。。

这个是什么问题?到底要怎么弄?
难道你是监测到文件变化后去同步完成就好了么?为啥还要隔一段时间轮询一次目录啊


  1. sent 16,559,294 bytes  received 9,062 bytes  241,873.81 bytes/sec
  2. total size is 654,649,017,020  speedup is 39,512.01
  3. was rsyncd
  4. sending incremental file list

  5. sent 16,559,302 bytes  received 9,070 bytes  241,874.04 bytes/sec
  6. total size is 654,649,017,020  speedup is 39,511.97
  7. was rsyncd
  8. sending incremental file list

  9. sent 16,559,306 bytes  received 9,074 bytes  241,874.16 bytes/sec
  10. total size is 654,649,017,020  speedup is 39,511.95
  11. was rsyncd
  12. sending incremental file list

  13. sent 16,559,298 bytes  received 9,066 bytes  241,873.93 bytes/sec
  14. total size is 654,649,017,020  speedup is 39,511.99
  15. was rsyncd
  16. sending incremental file list

  17. sent 16,559,290 bytes  received 9,058 bytes  241,873.69 bytes/sec
  18. total size is 654,649,017,020  speedup is 39,512.03
  19. was rsyncd
  20. sending incremental file list

  21. sent 16,559,302 bytes  received 9,070 bytes  241,874.04 bytes/sec
  22. total size is 654,649,017,020  speedup is 39,511.97
  23. was rsyncd
  24. sending incremental file list

  25. sent 16,559,218 bytes  received 8,986 bytes  238,391.42 bytes/sec
  26. total size is 654,649,017,020  speedup is 39,512.37
  27. was rsyncd
  28. sending incremental file list
复制代码


作者: xcy1020    时间: 2019-8-21 00:16
用lsyncd
作者: 醉里耍大刀    时间: 2019-8-21 00:16
文件数量多的时候,用这个就不靠谱了,非常消耗资源,可以做主动同步
作者: why?    时间: 2019-8-21 12:56
实时性不高的话建议定时任务,或者试试lsyncd




欢迎光临 全球主机交流论坛 (https://mjj.022333.xyz/) Powered by Discuz! X3.4