10 months ago

Log Permission Denied

Posted 10 months ago by kinshara

I have my Web Application host in Linux by Nginx. there is some process running:

  1. Queue job triggered by dispatch.
  2. Cron to the scheduler that runs every minute.

Logging Configuration is Daily. And inside bootstrap/app.php I configure this

$app->configureMonologUsing(function(Monolog\Logger $monolog) {
    $filename = storage_path('logs/laravel-'.php_sapi_name().'-'.get_current_user().'.log');
    $handler = new Monolog\Handler\RotatingFileHandler($filename);

Every day the log created with "root" name from get_current_user(). and every new day, if the new log file created by Cron, the Queue job will not work because Permission Denied writing the log file.

I tried to fix, by adjusting the Cron by installing as www-data user install inside

crontab -u www-data -e

by the log file still, create with "root" name.

and then I tried inside the Cron command, I add

* * * * * -u www-data php /directory/to/my/application/artisan schedule:run

the only solution that I know for now, only change the permission to 755 every day or every time the error occurred.

is there any other solution?

Please sign in or create an account to participate in this conversation.