This is what I'm trying to achieve :
User uploads file1.jpg to Server A
Using wget Server B only downloads file1.jpg from Server A if the file is newer than the one that already exists on Server B and then replaces the file on Server B with the new one.
I know I can use :
wget -N http://www.mywebsite.com/files/file1.jpg
wget -N http://www.mywebsite.com/files/file1.jpg /serverb/files/file1.jpg
You can use
-P option to specify the directory where the file(s) will be downloaded:
$ wget -N -P /serverb/files/ http://www.mywebsite.com/files/file1.jpg
You are also talking about downloading and replacing the file. Be aware, that
wget overwrites the file, so it is "broken" while being downloaded. I don't think you can do atomic replacement of the file using only
wget. You need a small script that uses temporary files and
move to atomically replace the file in Server B.