Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permissions error after clearing cache via CRON

I have an app running in production on nginx/passenger. Due to some issues I had to set up a CRON for weekly cache clearing. Now every Monday after it clears the cache the app stops working with an error message similar to

Permission denied - /var/www/myapp/tmp/cache/609/E30/configuration_1

To fix it I have to manually change the ownership of the app directory:

chown -R nobody:nogroup /var/www/myapp

The CRON is running under the web server user nobody:

@weekly cd /var/www/myapp && /usr/local/bin/ruby /usr/local/bin/rake tmp:cache:clear

I also tried adding && chown -R nobody:nogroup /var/www/myapp to crontab with no luck.

What am I doing wrong?

like image 332
Vincent Avatar asked Jan 29 '26 00:01

Vincent


1 Answers

Have you tried adding && chown -R nobody:nogroup /var/www/myapp/tmp/cache to the cronjob? Changing only the ownership of /var/www/myapp is not enough, the web server will need write access to the tmp/cache subdirectory, too.

like image 94
eugen Avatar answered Jan 30 '26 14:01

eugen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!