Permission error after clearing cache via CRON

I have an application running in production on nginx / passenger. Due to some problems, I had to configure CRON to clear the cache per week. Now, every Monday after clearing the cache, the application stops working with an error message similar to

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

To fix this, I need to manually change the ownership of the application directory:

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

CRON runs as a 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/myappto crontab with no luck.

What am I doing wrong?

+3
source share
1 answer

&& chown -R nobody:nogroup /var/www/myapp/tmp/cache cronjob? /var/www/myapp , - tmp/cache.

+2

All Articles