Sunday, 17 August 2014

Sync Unix machines using Rsync and Cron job

In Ruby, write cron jobs using  whenever gem .

In schedule.rb file write:

every 1.day, at: '11pm' do
  command "rsync -az --delete file_path_to_sync/ Ip_address_of_destination:/file_path"
end

we will need to login remote server without password

  • Create public and private keys 

  • ssh-keygen
  • Copy the public key to remote-host

  • ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
More details