magento2: Magento ver. 2.1.0 - Cron /bin/magento cron:run Permission denied in /vendor/colinmollenhour/cache-backend-file/File.php
Magento ver. 2.1.0, Implementation of cron as per documentation on [(http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html#config-cli-cron-group-run)]
* * * * * /usr/bin/php /var/www/magento2/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /var/www/magento2/var/log/magento.cron.log
* * * * * /usr/bin/php /var/www/magento2/update/cron.php >> /var/www/magento2/var/log/update.cron.log
* * * * * /usr/bin/php /var/www/magento2/bin/magento setup:cron:run >> /var/www/magento2/var/log/setup.cron.log
Results in error log reporting the following when line one in cron runs, the other two run without issues.
Subject: Cron <ec2-user@domainname.com> /usr/bin/php /var/www/vhosts/magento2/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /var/www/vhosts/magento2/var/log/magento.cron.log
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env: <LANG=en_US.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/ec2-user>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=ec2-user>
X-Cron-Env: <USER=ec2-user>
[Exception]
Warning: file_put_contents(/var/www/vhosts/magento2/var/cache//mage-tags/mage---1b8_CONFIG): failed to open stream: Permission denied in /var/www/vhosts/magento2/vendor/colinmollenhour/cache-backend-file/File.php on line 663
cron:run [--group="..."] [--bootstrap="..."]
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (6 by maintainers)
I used apache as webserver and this cron setting fixed my issue:
I run a magento 2 instance on aws ubuntu 14.04 trusty
@wired-circuit why don’t you let magento run as www-data:www-data? It just makes things easier.
But to be honest I had the same issue after running the
setup:static-content:deploy
command. Trying to open the magento2-instance in chrome: Permission Denied: Some Cache File has the ownership root:root with restricted rights -> execution error, because webserver-user can’t open/read it.The problem was that I executed the command as root-user. All
php bin/magento
commands should be run as file-owner/webserver-user, e.g. as www-data.just simply execute magento commands like:
sudo -u www-data php bin/magento setup:static-content:deploy de_DE
sudo -u www-data php bin/magento cache:flush
and so on…that should do the trick. hopefully it’s not too late for you!