Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

chmod routine 2

Status
Not open for further replies.

BlindPete

Programmer
Joined
Jul 5, 2000
Messages
711
Location
US
Hello All,

I'm hoping someone has a function they can share to do this for me.

I want to be able CHMOD(666) or CHMOD(777) an entire directory branch, including all files and sub folders.

Its an APACHE server on a LINUX box.

If anyone has a cron script that would do fine.

thanks a bunch!

-Pete
Do you get a little guilty pleasure when a celebrity has a bad day?
Well then The Dead Pool is for you!
 
chmod 777 is never a good idea. You never know when world write permissions can lead to problems, so avoiding it is a good idea.


I'd just run:

chmod -R [permissions] /path/to/directory

as an external command using either shellexec() or the backtick operator



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
This can be easily done with system commands, and as such I don't think a PHP script would be better. The PHP would also just work if the command line version of PHP is installed.
IMO you are much better off with a regular chron job that uses find, something like
Code:
find . -type -f -exec chmod 666 {}\;
 
I agree on the 777. the path in question is also htaccess protected

help me out alittle more with the cron. I'm really bad at it.

say my parent path is:
\public_html\files
under that is much directory structure and many files that I want to CHMOD 666

so would the CRON line look like this?
Code:
find \public_html\files\. -type -f -exec chmod 666 {}\;



-Pete
Do you get a little guilty pleasure when a celebrity has a bad day?
Well then The Dead Pool is for you!
 
Since we are no longer discussing PHP, I think you would be better served asking about cron in an OS-specific forum.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top