Root Cron job doesn't perform chmod

Clash 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:
- Although I am setting the umask to
007, the actual permissions are not as expected. - Although I am explicitly changing permissions(
chmod 770) to theTARGETdir, 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
 |Â
show 1 more comment
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:
- Although I am setting the umask to
007, the actual permissions are not as expected. - Although I am explicitly changing permissions(
chmod 770) to theTARGETdir, 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
1
Does it work withoutcron? I suspect thersync -ato 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 thersynccommand, the permissions were set correctly. Seemsrsyncoverwrites them..
â CuriousGuy
Mar 18 at 17:39
Show output ofstat --printf "%a" /.
â Cyrus
Mar 18 at 17:40
2
Swapchmodandrsync.
â Cyrus
Mar 18 at 17:41
 |Â
show 1 more comment
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:
- Although I am setting the umask to
007, the actual permissions are not as expected. - Although I am explicitly changing permissions(
chmod 770) to theTARGETdir, 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
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:
- Although I am setting the umask to
007, the actual permissions are not as expected. - Although I am explicitly changing permissions(
chmod 770) to theTARGETdir, 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
16.04 bash cron rsync
edited Mar 18 at 17:35
asked Mar 18 at 17:27
CuriousGuy
1213
1213
1
Does it work withoutcron? I suspect thersync -ato 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 thersynccommand, the permissions were set correctly. Seemsrsyncoverwrites them..
â CuriousGuy
Mar 18 at 17:39
Show output ofstat --printf "%a" /.
â Cyrus
Mar 18 at 17:40
2
Swapchmodandrsync.
â Cyrus
Mar 18 at 17:41
 |Â
show 1 more comment
1
Does it work withoutcron? I suspect thersync -ato 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 thersynccommand, the permissions were set correctly. Seemsrsyncoverwrites them..
â CuriousGuy
Mar 18 at 17:39
Show output ofstat --printf "%a" /.
â Cyrus
Mar 18 at 17:40
2
Swapchmodandrsync.
â 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
 |Â
show 1 more comment
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).
add a comment |Â
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).
add a comment |Â
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).
add a comment |Â
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).
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).
answered Mar 18 at 17:45
CuriousGuy
1213
1213
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Does it work without
cron? I suspect thersync -ato 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
rsynccommand, the permissions were set correctly. Seemsrsyncoverwrites them..â CuriousGuy
Mar 18 at 17:39
Show output of
stat --printf "%a" /.â Cyrus
Mar 18 at 17:40
2
Swap
chmodandrsync.â Cyrus
Mar 18 at 17:41