0

I have a copy script that runs in a crontab and I need the folder and files that are copied to inherit the permissions of the destination directory.

This is the destination folder:

drwxrwxr-x 10 usr1 group1 151 Apr 24 12:47 folder1

When I run the following command, it works as expected and the test3 folder and files all inherit the permission of "folder1":

/usr/bin/cp -r --no-preserve=mode,ownership /home/usr1/jobs/test3 /s0/folder1/

drwxrwxr-x  3 usr1 group1 54 Apr 24 12:53 test3

When I put the same command into a crontab, the group write permission is not inherited:

#* * * * * /usr/bin/cp -r --no-preserve=mode,ownership /home/usr1/jobs/test2 /s0/folder1/

drwxr-xr-x  3 usr1 group1 54 Apr 24 12:52 test2

Any ideas what is going on?

2
  • (1) Why does your crontab line begin with a #? (2) What are the permissions on the source testN directories (in /home/usr1/jobs)?  (3) Have you looked at umask? Commented Apr 24 at 18:42
  • (1) Just used # for formatting, otherwise it put a bunch of bullets. It isn't actually commented out. (2) drwxrwxr-x 82 usr1 group1 8.0K Apr 24 12:40 jobs and drwxrwxr-x 3 usr1 group1 100 Apr 24 12:24 test3 (3) Yes, umask is set to 0002 for this user Commented Apr 24 at 18:54

1 Answer 1

0

Did you ever try this :

tar cfp - /home/usr1/jobs/test3 | ( cd /s0/folder1/;tar xfp -)

reference this .

1
  • $ man tar ← -p, --same-permissions, --preserve-permissions
    – James
    Commented Apr 25 at 1:03

You must log in to answer this question.

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