Skip to content

Instantly share code, notes, and snippets.

@drio
Created April 13, 2010 19:10
Show Gist options
  • Save drio/364962 to your computer and use it in GitHub Desktop.
Save drio/364962 to your computer and use it in GitHub Desktop.
ruby fork rsync
#!/usr/bin/env ruby19
#
ses = %w{
/stornext/snfs1/next-gen/solid/results/solid0301/0301_20091103_1_SP/AWG_TCGA_GBM_02_T_000sA_01003244545_1/results.F1B1
/stornext/snfs1/next-gen/solid/results/solid0301/0301_20091103_1_SP/AWG_TCGA_GBM_02_T_000sA_01003244545_2/results.F1B1
/stornext/snfs1/next-gen/solid/results/solid0301/0301_20091103_1_SP/ANG_HSAP_NG_003sA_01003244545_3/results.F1B1
/stornext/snfs1/next-gen/solid/results/solid0301/0301_20091103_1_SP/ANG_HSAP_NG_003sA_01003244545_4/results.F1B1
/stornext/snfs4/next-gen/solid/results/solid0446/0446_20091125_1_SL/AWG_TCGA_OVA_01_T_000sA_01003244597_1/results.F1B1
}
def ctrl_c
puts "ctrl + c ..."
@childrens.each {|c| puts "Killing #{c} ..."; Process.kill("HUP", c) }
exit 1
end
trap("SIGINT") { ctrl_c }
ssh_url = "[email protected]"
@childrens = []
ses.each do |s|
s.chomp!
ss = s.split('/')
r_name, lib = ss[7..8]
sea = r_name + "_" + lib
Dir.mkdir(sea) unless File.exists?(sea)
Dir.chdir(sea) do
puts "Forking: #{sea}"
@childrens << fork { `rsync -avz --progress -e ssh #{ssh_url}:#{s} .` }
end
end
p Process.waitall
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment