LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   find : permission denied (http://www.linuxquestions.org/questions/linux-newbie-8/find-permission-denied-819050/)

marvelade 07-10-2010 04:42 AM

find : permission denied
 
Hey all,

I'm using the find command in a PHP script like this to update permissions on all files but not directories:

<?php

// whole bunch of code

exec("find /var/www/vhosts/mydomain.com/httpdocs/path/to/some/directory -type f -exec chmod -R 440 {} \;");

// whole bunch of other code

?>

The PHP script runs daily with a cron tab.


When I run the script in a browser I get no error messages.

When the crontab runs the script I get this error:

find: /var/www/vhosts/mydomain.com/httpdocs/path/to/some/directory: Permission denied


The PHP script is owned by user www-data, which is the user that PHP runs as on this server (at least that's the result I get when I do

exec("whoami"); // outputs: www-data

).

The crontab is owned by root and looks like this:

10 3 * * * php -q /var/www/vhosts/mydomain.com/httpdocs/crontab_collection_dir/do_some_fancy_stuff.cron.php


at 3:10 AM the script is run by root (I write results to a log file using PHP including the result of "whoami" which says "root")



How is it possible that root can't execute a find command on a directory that it doesn't own?

Should I now officially burn my T-shirt saying "Bow before me, for I am root" ?


best regards,
Marvelade

marvelade 07-10-2010 04:45 AM

P.S.: My guess was to run all crontabs as root to avoid these kinds of problems...


All times are GMT -5. The time now is 12:57 PM.