Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

There is a serverA with a folder folder1, in folder1 there are different files: bar.htm, test.jpg, test2.jpg, foo.txt, folder1/subfolder1/test3.jpg, etc.

There is a serverB with an empty folder2

I want to constantly sync *.jpg files from serverA to serverB, so that serverB will have test.jpg and test2.jpg, test3.jpg and other .jpg files it can find in subdirectories of the serverA.

Also, I want it work automatically, without requesting password prompt.

Two CentOS servers. I understand that it is best to use rsync, cron, but how should I do?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Something like this:

for f in `find . -name "*.jpg"`; do rsync $f serverB: ; done

You need to then run it on account that has SSH key with blank password to accessing the serverB.

Note: This fails if files are removed. If you want files deleted from serverB when they are deleted from serverA, then you need to change this.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.