Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .