Laravel 日志写入权限被拒绝

Say*_*Das 1 php laravel

我在 Laravel 应用程序中写入日志时面临权限问题。我们有每日日志,因此每天都会创建一个新的日志文件。项目文件夹所有权设置为www-data. 并且日志通常是经过www-data许可生成的。但有时日志是由root用户创建的,然后如果我尝试在日志中写入内容,我会被拒绝并且应用程序崩溃。

-rw-r--r-- 1 www-data www-data 77016 Sep 12 05:00 laravel-2017-09-11.log
-rw-r--r-- 1 root     root      1240 Sep 12 10:30 laravel-2017-09-12.log
Run Code Online (Sandbox Code Playgroud)

For example, yesterday's log was created by www-data but today it's under root. So I am getting crashes everytime. If I delete the log or change the permission to 777 then it solves for a while until it pops up again. I cannot replicate the issue and don't know why logs are being created under root user. Any help would be appriciated. Thank you.

Pub*_*ana 6

您可以以 www-data 用户身份运行 cron。

前任:* * * * * www-data php /path/to/artisan schedule:run >> /dev/null 2>&1