This is a copy of http://drupal.org/node/960702, after posting it there I wasn't sure if it's not better to put it here as a support request:
A few days ago I started getting a couple of errors every time cron ran when I would upload an image (I use imagefield, filefield and CCK) and then leave the node without uploading it. The cronjob would then be tasked with removing the file and would fail (more on that here: http://drupal.org/node/958784). However, today I checked my logs and discovered a horrendous flood of errors during the last cron run, all saying variations of this:
unlink(sites/default/files/js/js_49b30f9031391231ea218f5aa2790a7e.js) [function.unlink]: Permission denied in /home/bottlewe/public_html/warmdebate.com/includes/file.inc on line 471.
So this is obviously not just a CCK issue but there must be something wrong with my permissions, I just don't know what. Here are my current permissions according to my ftp client:
sites 755
sites/default xxx
sites/default/files 777
sites/default/files/filename.xxx 644
sites/default/files/js 755
sites/default/files/js/filename.xxx 644
by filename.xxx I mean all the individual files. Maybe these files should be 755 instead of 644? But how do I change the default? In "Status report" under filesystem there is no error (green tick) and it says " Writable (public download method)". For the record my site runs fine, I would never have guessed there was a problem if I didn't check the logs, here are the versions of relevant modules I'm using (all latest updates):
Core 6.19
CCK 6.x-2.8
FileField 6.x-3.7
ImageField 6.x-3.7
Thanks for any advice in advance.
Comments
Comment #1
armanschwarz commentedStill having this problem, would really appreciate some help.
Comment #2
xjmI get these as well. It's likely not a permissions problem so much as an owner/group problem. If you check the owner and group of these files, you will probably see that both are the web server's user. Makes sense since these files are created automatically by Drupal. So, other users don't have permission to delete them.
For example, when I run a drush command that flushes the cache as my own user, I get the error messages for all the optimized css and js files. If I do it as root, or sudo it as the web server's user, there are no errors and the files are properly deleted.
If the errors appear on a cron run, I'm guessing it might have something to do with which user runs cron.
The errors are merely an annoyance, really. They're just old CSS/JS cache files, so it's nothing to worry about unless you're running out of disk space.
Comment #3
xjmBy the way, creating 18 different posts about the same issue is not recommended. Don't think of your posts as requests for help; think of them as records of a problem that you want someone else to find. The more people find it, the more likely it is to get fixed. Opening new issues or forum threads just because the first one hasn't helped so far just makes it harder for people to find all that's been said about the issue.
For anyone else who stumbles on this, see also:
http://drupal.org/node/960702
http://drupal.org/node/958784
http://drupal.org/node/965208
http://drupal.org/node/963912
Comment #4
armanschwarz commentedThanks for the help. So how would I go about fixing this? How do I set the user that runs cron? My cron command looks like this:
php -q /home/public_html/cron.php > /dev/null 2>&1