# Cron Job For Permissions Inheritance



## gregarios (Nov 25, 2002)

I know how to chmod or chown individual files or folders, but how would I do one of these commands to cause a whole folder full of files to all receive the same chown or chmod settings? I'm trying to make a crontab that would allow me to set the permissions and ownership of a folder and the folders/files in it, every 5 minutes.

This way, whenever a user creates a file/folder in the target directory, it would change ownership from "theirs" to "ours" essentially, regardless of who created it.


----------



## anarchie (Nov 26, 2002)

chmod -R perms files ...
chown -R user files ...
chgrp -R group files ...


----------



## gregarios (Nov 26, 2002)

I hate to be a pain, but could you explain your answer just a bit? What are the "..." or "files"?

I don't have any way to know what files will be in the folders.


----------



## anarchie (Nov 26, 2002)

Sorry, I was feeling quite terse at the time.  The -R option causes the aforementioned commands to recursively descend into subdirectories.  You can, for instance, "chmod -R anarchie /Library/Webserver/Documents" to make anarchie the owner of everything on your personal web server.  If you don't know what files will be in the folder, just apply the command to the folder itself.


----------



## gregarios (Nov 26, 2002)

Thanks very much.


----------



## gregarios (Nov 27, 2002)

Hmmm...  ok. I've got it *mostly* working...

How come I can enter this in the command line after booting into root:

chown -R differentowner:differentgroup /Volumes/volumename/folder

...and it changes the owner and group of the folder and any folders/files in it perfectly.

However, if I put it in the root crontab, it doesn't do it! My chmod commands work in the root crontab though, perfectly. Any reason why that is?


----------



## anarchie (Nov 27, 2002)

The cron process isn't guaranteed to have its PATH environment variable set.  Try using the full path to chown (/usr/sbin/chown on my machine) instead of just 'chown'.


----------

