Root Cron job doesn't perform chmod

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite












I have a root cron job which creates a directory in a mounted different HDD and then using rsync I am copying all files from SOURCE to TARGET. Script looks like this:



 date_cmd='date +%Y_%m_%d_%H_%M_%S'
TS_SUFFIX=`eval $date_cmd`
SOURCE_DIR=/
TARGET_DIR=/mnt/backup_hdd/system_backup_$TS_SUFFIX

LOG_DIR=/shared_utils/logs/backupper
LOG_FILE=$LOG_DIR/backupper_$TS_SUFFIX.log

mkdir -p $TARGET_DIR
chmod 770 $TARGET_DIR
rsync -a --append-verify --info=progress2 --exclude-from=$EXCLUDE_LIST $SOURCE_DIR $TARGET_DIR


The problem is that chmod 770 doesn't change the TARGET dir permisisons to 770. As you see it is created with 755 permissions.:



drwxr-xr-x 19 root root 4096 Mar 18 11:47 system_backup_2018_03_18_17_57_01/


My root cron job:



57 17 * * * umask 007; /path/to/script.sh


As you see I set umask 007 before executing the script. So, it fails on 2 fronts:



  1. Although I am setting the umask to 007, the actual permissions are not as expected.

  2. Although I am explicitly changing permissions(chmod 770) to the TARGET dir, permissions are still not changed.

Any ideas why these 2 cases don't work?



UPDATE



Running the script with sudo script.sh doesn't change the permissions of TARGET, either.










share|improve this question



















  • 1




    Does it work without cron? I suspect the rsync -a to set the permissions similar to the source directory.
    – PerlDuck
    Mar 18 at 17:31










  • @PerlDuck Nope. I will update question :)
    – CuriousGuy
    Mar 18 at 17:34










  • @PerlDuck Seems you are right. When commented the rsync command, the permissions were set correctly. Seems rsync overwrites them..
    – CuriousGuy
    Mar 18 at 17:39










  • Show output of stat --printf "%a" /.
    – Cyrus
    Mar 18 at 17:40







  • 2




    Swap chmod and rsync.
    – Cyrus
    Mar 18 at 17:41














up vote
0
down vote

favorite












I have a root cron job which creates a directory in a mounted different HDD and then using rsync I am copying all files from SOURCE to TARGET. Script looks like this:



 date_cmd='date +%Y_%m_%d_%H_%M_%S'
TS_SUFFIX=`eval $date_cmd`
SOURCE_DIR=/
TARGET_DIR=/mnt/backup_hdd/system_backup_$TS_SUFFIX

LOG_DIR=/shared_utils/logs/backupper
LOG_FILE=$LOG_DIR/backupper_$TS_SUFFIX.log

mkdir -p $TARGET_DIR
chmod 770 $TARGET_DIR
rsync -a --append-verify --info=progress2 --exclude-from=$EXCLUDE_LIST $SOURCE_DIR $TARGET_DIR


The problem is that chmod 770 doesn't change the TARGET dir permisisons to 770. As you see it is created with 755 permissions.:



drwxr-xr-x 19 root root 4096 Mar 18 11:47 system_backup_2018_03_18_17_57_01/


My root cron job:



57 17 * * * umask 007; /path/to/script.sh


As you see I set umask 007 before executing the script. So, it fails on 2 fronts:



  1. Although I am setting the umask to 007, the actual permissions are not as expected.

  2. Although I am explicitly changing permissions(chmod 770) to the TARGET dir, permissions are still not changed.

Any ideas why these 2 cases don't work?



UPDATE



Running the script with sudo script.sh doesn't change the permissions of TARGET, either.










share|improve this question



















  • 1




    Does it work without cron? I suspect the rsync -a to set the permissions similar to the source directory.
    – PerlDuck
    Mar 18 at 17:31










  • @PerlDuck Nope. I will update question :)
    – CuriousGuy
    Mar 18 at 17:34










  • @PerlDuck Seems you are right. When commented the rsync command, the permissions were set correctly. Seems rsync overwrites them..
    – CuriousGuy
    Mar 18 at 17:39










  • Show output of stat --printf "%a" /.
    – Cyrus
    Mar 18 at 17:40







  • 2




    Swap chmod and rsync.
    – Cyrus
    Mar 18 at 17:41












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a root cron job which creates a directory in a mounted different HDD and then using rsync I am copying all files from SOURCE to TARGET. Script looks like this:



 date_cmd='date +%Y_%m_%d_%H_%M_%S'
TS_SUFFIX=`eval $date_cmd`
SOURCE_DIR=/
TARGET_DIR=/mnt/backup_hdd/system_backup_$TS_SUFFIX

LOG_DIR=/shared_utils/logs/backupper
LOG_FILE=$LOG_DIR/backupper_$TS_SUFFIX.log

mkdir -p $TARGET_DIR
chmod 770 $TARGET_DIR
rsync -a --append-verify --info=progress2 --exclude-from=$EXCLUDE_LIST $SOURCE_DIR $TARGET_DIR


The problem is that chmod 770 doesn't change the TARGET dir permisisons to 770. As you see it is created with 755 permissions.:



drwxr-xr-x 19 root root 4096 Mar 18 11:47 system_backup_2018_03_18_17_57_01/


My root cron job:



57 17 * * * umask 007; /path/to/script.sh


As you see I set umask 007 before executing the script. So, it fails on 2 fronts:



  1. Although I am setting the umask to 007, the actual permissions are not as expected.

  2. Although I am explicitly changing permissions(chmod 770) to the TARGET dir, permissions are still not changed.

Any ideas why these 2 cases don't work?



UPDATE



Running the script with sudo script.sh doesn't change the permissions of TARGET, either.










share|improve this question















I have a root cron job which creates a directory in a mounted different HDD and then using rsync I am copying all files from SOURCE to TARGET. Script looks like this:



 date_cmd='date +%Y_%m_%d_%H_%M_%S'
TS_SUFFIX=`eval $date_cmd`
SOURCE_DIR=/
TARGET_DIR=/mnt/backup_hdd/system_backup_$TS_SUFFIX

LOG_DIR=/shared_utils/logs/backupper
LOG_FILE=$LOG_DIR/backupper_$TS_SUFFIX.log

mkdir -p $TARGET_DIR
chmod 770 $TARGET_DIR
rsync -a --append-verify --info=progress2 --exclude-from=$EXCLUDE_LIST $SOURCE_DIR $TARGET_DIR


The problem is that chmod 770 doesn't change the TARGET dir permisisons to 770. As you see it is created with 755 permissions.:



drwxr-xr-x 19 root root 4096 Mar 18 11:47 system_backup_2018_03_18_17_57_01/


My root cron job:



57 17 * * * umask 007; /path/to/script.sh


As you see I set umask 007 before executing the script. So, it fails on 2 fronts:



  1. Although I am setting the umask to 007, the actual permissions are not as expected.

  2. Although I am explicitly changing permissions(chmod 770) to the TARGET dir, permissions are still not changed.

Any ideas why these 2 cases don't work?



UPDATE



Running the script with sudo script.sh doesn't change the permissions of TARGET, either.







16.04 bash cron rsync






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 18 at 17:35

























asked Mar 18 at 17:27









CuriousGuy

1213




1213







  • 1




    Does it work without cron? I suspect the rsync -a to set the permissions similar to the source directory.
    – PerlDuck
    Mar 18 at 17:31










  • @PerlDuck Nope. I will update question :)
    – CuriousGuy
    Mar 18 at 17:34










  • @PerlDuck Seems you are right. When commented the rsync command, the permissions were set correctly. Seems rsync overwrites them..
    – CuriousGuy
    Mar 18 at 17:39










  • Show output of stat --printf "%a" /.
    – Cyrus
    Mar 18 at 17:40







  • 2




    Swap chmod and rsync.
    – Cyrus
    Mar 18 at 17:41












  • 1




    Does it work without cron? I suspect the rsync -a to set the permissions similar to the source directory.
    – PerlDuck
    Mar 18 at 17:31










  • @PerlDuck Nope. I will update question :)
    – CuriousGuy
    Mar 18 at 17:34










  • @PerlDuck Seems you are right. When commented the rsync command, the permissions were set correctly. Seems rsync overwrites them..
    – CuriousGuy
    Mar 18 at 17:39










  • Show output of stat --printf "%a" /.
    – Cyrus
    Mar 18 at 17:40







  • 2




    Swap chmod and rsync.
    – Cyrus
    Mar 18 at 17:41







1




1




Does it work without cron? I suspect the rsync -a to set the permissions similar to the source directory.
– PerlDuck
Mar 18 at 17:31




Does it work without cron? I suspect the rsync -a to set the permissions similar to the source directory.
– PerlDuck
Mar 18 at 17:31












@PerlDuck Nope. I will update question :)
– CuriousGuy
Mar 18 at 17:34




@PerlDuck Nope. I will update question :)
– CuriousGuy
Mar 18 at 17:34












@PerlDuck Seems you are right. When commented the rsync command, the permissions were set correctly. Seems rsync overwrites them..
– CuriousGuy
Mar 18 at 17:39




@PerlDuck Seems you are right. When commented the rsync command, the permissions were set correctly. Seems rsync overwrites them..
– CuriousGuy
Mar 18 at 17:39












Show output of stat --printf "%a" /.
– Cyrus
Mar 18 at 17:40





Show output of stat --printf "%a" /.
– Cyrus
Mar 18 at 17:40





2




2




Swap chmod and rsync.
– Cyrus
Mar 18 at 17:41




Swap chmod and rsync.
– Cyrus
Mar 18 at 17:41










1 Answer
1






active

oldest

votes

















up vote
0
down vote













Thanks to PerlDuck and Cyrus the mystery is solved.



rsync -a creates the TARGET dir with the same permissions as the SOURCE(in my case 755).






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1017055%2froot-cron-job-doesnt-perform-chmod%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Thanks to PerlDuck and Cyrus the mystery is solved.



    rsync -a creates the TARGET dir with the same permissions as the SOURCE(in my case 755).






    share|improve this answer
























      up vote
      0
      down vote













      Thanks to PerlDuck and Cyrus the mystery is solved.



      rsync -a creates the TARGET dir with the same permissions as the SOURCE(in my case 755).






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Thanks to PerlDuck and Cyrus the mystery is solved.



        rsync -a creates the TARGET dir with the same permissions as the SOURCE(in my case 755).






        share|improve this answer












        Thanks to PerlDuck and Cyrus the mystery is solved.



        rsync -a creates the TARGET dir with the same permissions as the SOURCE(in my case 755).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 18 at 17:45









        CuriousGuy

        1213




        1213



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1017055%2froot-cron-job-doesnt-perform-chmod%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            GRUB: Fatal! inconsistent data read from (0x84) 0+xxxxxx

            What makes Checkinstall packages not suitable for distribution?

            Running the scala interactive shell from the command line