I'm trying to sync specific cron files between 2 servers and change the permissions for them. However, the command I am trying is also changing the permissions on the main directory.

Command used:

rsync -ai --no-o --no-g --chmod=644 --delete --include='ccron_*' --exclude='*' /etc/ccrons/ root@worker:/etc/cron.d/

That causes the directory /etc/cron.d on the destination machine to have the permissions 644 as well.

It works when I add wildcard to the source folder (/etc/ccrons/*) but then --delete doesn't work and files that were deleted in the source are not deleted in the destination.

I'm using rsync 3.1.0 on Ubuntu 14.04.3 LTS

  • 1
    If you are not transferring subdirs, my rsync allows --chmod=F644 to only affect file permissions. – meuh Mar 18 '16 at 17:23
  • Thanks @meuh. Actually I went to manual and read that right after I posted this thread. -_-. This works for me. I had to add D755 as well to keep the permissions as it was on /etc/cron.d. Luckily I don't have sub-folders. – Erico Mar 18 '16 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.