Cron file permission help
I have a cron set up to run every 5mins to fix file permissions for the SFTP server I have up.
Here is my script:
FOLDERS=/Volumes/Server/Trainer/*
logger Cron Perm Script Start
for f in $FOLDERS
do
if [ $f != "/Volumes/Server/Trainer/scripts" ]; then
user=`stat -f %u $f/uploads`
folder="${f}/uploads"
response=`chown -R $user $folder`
responsetwo=`chmod -R 770 $folder`
logger response $response $responsetwo
fi
done
logger Cron Perm Script End
exit 0
If I execute the script myself as root it works fine and all the permissions get fixed. It gets run fine through the cron service but it won't fix the permissions. I've tried to debug this numerous ways but haven't figured out what I'm doing wrong.
$folder has the right path.
$user is the right user id.
the logger calls show up in the console so I know it's running.
11-09-28 11:10:00.960 AM root: Cron Perm Script Start
11-09-28 11:10:00.965 AM root: response
11-09-28 11:10:00.969 AM root: response
11-09-28 11:10:00.975 AM root: response
11-09-28 11:10:00.980 AM root: response
11-09-28 11:10:00.985 AM root: response
11-09-28 11:10:00.990 AM root: response
11-09-28 11:10:00.994 AM root: response
11-09-28 11:10:00.999 AM root: response
11-09-28 11:10:01.004 AM root: response
11-09-28 11:10:01.009 AM root: response
11-09-28 11:10:01.013 AM root: response
11-09-28 11:10:01.018 AM root: response
11-09-28 11:10:01.023 AM root: response
11-09-28 11:10:01.027 AM root: response
11-09-28 11:10:01.032 AM root: response
11-09-28 11:10:01.037 AM root: response
11-09-28 11:10:01.041 AM root: response
11-09-28 11:10:01.046 AM root: response
11-09-28 11:10:01.050 AM root: response
11-09-28 11:10:01.055 AM root: response
11-09-28 11:10:01.061 AM root: response
11-09-28 11:10:01.065 AM root: response
11-09-28 11:10:01.070 AM root: response
11-09-28 11:10:01.078 AM root: response
11-09-28 11:10:01.083 AM root: response
11-09-28 11:10:01.089 AM root: response
11-09-28 11:10:01.095 AM root: response
11-09-28 11:10:01.100 AM root: response
11-09-28 11:10:01.106 AM root: response
11-09-28 11:10:01.112 AM root: response
11-09-28 11:10:01.118 AM root: response
11-09-28 11:10:01.124 AM root: response
11-09-28 11:10:01.129 AM root: response
11-09-28 11:10:01.134 AM root: response
11-09-28 11:10:01.140 AM root: response
11-09-28 11:10:01.145 AM root: response
11-09-28 11:10:01.149 AM root: response
11-09-28 11:10:01.151 AM root: Cron Perm Script End
Any help is greatly appreciated.
Thanks.