报错
在以schedule方式执行定时命令时遇到报错
1 |
local.ERROR: file_put_contents(/var/www/laravel/storage/framework/cache/data/ac/13/ac1346822aa47576e6930144a7f0c0d296a1f95f): failed to open stream: Permission denied {"exception":"[object] (ErrorException(code: 0): file_put_contents(/var/www/laravel/storage/framework/cache/data/ac/13/ac1346822aa47576e6930144a7f0c0d296a1f95f): failed to open stream: Permission denied at /var/www/laravel/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:187) |
分析原因
因为在调试定时命令的时候直接在shell以root身份通过php命令执行artisan命令,而这个command里包含了Cache方法,导致Cache的内容权限依旧是root的,所以当以www-data身份运行定时命令时导致无权限写入Cache
1 |
php /var/www/laravel/artisan command:AutoGetContent |
解决方案
清空root创建的Cache缓存即可
1 |
php /var/www/laravel/artisan cache:clear |
There are no comments yet