I'm using rsync to update the content of a target directory to to be the same as a source directory from, i.e.: rsync -rt --delete from/ to/. I want to keep the time for the files in from, and found the --times/-t switch.

However, this will preserve the time of the directory as well, making to has the same modification time as from.

I would like to avoid this behaviour specifically, because the to directory is shared across a user group with permission 771, and other users (in the group) do not have the permission to modify the directory's modification time. Using rsync in this way will result in an error saying the time of to/. cannot be modified.

How can I achieve that?

  • 1
    Have you tried rsync -Ort .... ? That switch is on the very next line of the man page from the --times swtich. If that still doesn't work, please edit your post to show: ls -ld --full-time from/ to/ before; the exact rsync command you used and its output; and ls -ld --full-time from/ to/ after.
    – Jim L.
    Commented Jan 24 at 18:53
  • @JimL. That seems to work. Thanks! Weird I didn't see that switch. If you put it as an answer, I'll choose it.
    – renyuneyun
    Commented Feb 2 at 18:51

1 Answer 1


Use the -O switch from the rsync man page:

-O, --omit-dir-times omit directories from --times

rsync -Ort ....

You must log in to answer this question.

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