Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I've got a server where I do my web development and testing, and I have a bunch of frontend servers that sit behind a load balancer. I wrote a simple bash script to rsync a directory on my dev server to all of the production servers when I fix a bug, etc.

The rsync APPEARS to work, but when I actually go to the other servers, none of the files have been updated. What am I doing wrong?



echo "$directory"

set -x
for host in ""
    rsync -avz -e ssh ${directory} root@${host}:${directory}

At the moment I only have one ip address in the for loop, but I'll be adding more as time goes on. This is how I'm executing the script and the abbreviated output:

[root@admin vhosts]# ./ /var/www/scripts
+ for host in '""'
+ rsync -avz -e ssh /var/www/scripts
sending incremental file list

sent 7395053 bytes  received 1252 bytes  2113230.00 bytes/sec
total size is 36718000  speedup is 4.96
[root@admin vhosts]#

If I run the command again, rsync appears to work appropriately and as expected does not show any files in the list, ostensibly because they've all been updated. However, when I go and look at the files on server, they haven't been updated at all.

share|improve this question

migrated from Jun 14 '13 at 17:17

This question came from our site for professional and enthusiast programmers.

pick one file and find it in the destination, I think you are looking at (copying) to the wrong folder – perreal Jun 12 '13 at 23:44
Hm, you're right. I wonder if this has to do with having a trailing slash on ${directory} – Kenny Wyland Jun 13 '13 at 0:03
these are equivalent: rsync -av /src/foo /dest, rsync -av /src/foo/ /dest/foo – perreal Jun 13 '13 at 0:06
Right, my problem was occurring when I did rsync -av /src/foo user@host:/src/foo which was duplicating the directory as you suggested, creating /src/foo/foo – Kenny Wyland Jun 13 '13 at 0:08

Due to the strict requirements on trailing slashes when using rsync, I just needed to make sure to put a trailing slash when rsyncing a directory:


# ./ /var/www/scripts

vs Good:

# ./ /var/www/scripts/
share|improve this answer

Your Answer


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.