-   Linux - Newbie (
-   -   find : permission denied (

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:


// whole bunch of code

exec("find /var/www/vhosts/ -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/ 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/

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 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 05:56 AM.