Skip to content

Instantly share code, notes, and snippets.

@koki-h
Last active January 30, 2018 02:43
Show Gist options
  • Select an option

  • Save koki-h/c37d76b7d2f7f78fa1a450d72da6b1fb to your computer and use it in GitHub Desktop.

Select an option

Save koki-h/c37d76b7d2f7f78fa1a450d72da6b1fb to your computer and use it in GitHub Desktop.
同期元ディレクトリにファイルが次々に追加される中、rsyncするとどうなるか
# Ctrl-Cで止めてください
# bashで以下を実行すると同期元と同期先の差分が調べられます。
# diff <(ls -l src/) <(ls -l dst/)
require "fileutils"
include FileUtils
mkdir_p("src")
mkdir_p("dst")
t1 = Thread.start do
while true do
filename = "#{Time.now.to_f}.data"
puts "making file:#{filename}"
system("dd if=/dev/zero of=src/#{filename} bs=1024 count=1")
sleep(0.5)
end
end
t2 = Thread.start do
while true do
puts "rsync:"
system("rsync -av src/ dst/")
sleep(10)
end
end
t1.join
t2.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment