Cron Job For Permissions Inheritance

gregarios

Registered
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.
 
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.
 
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.
 
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?
 
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'.
 
Back
Top