I have Ubuntu 18.04, Laravel and PHP7.4. When I do for example command ls I have the list of folders and:

user1@bpl:/var/www/html/storage$ ls
app  framework  logs
You have new mail in /var/mail/user1

When I do cat /var/mail/user1 I have content of the file:

From user1@bpl  Tue Mar  3 14:30:01 2020
Return-Path: <user1@bpl>
X-Original-To: user1
Delivered-To: user1@bpl
Received: by bpl (Postfix, from userid 1000)
        id 3264910126D; Tue,  3 Mar 2020 14:30:01 +0000 (UTC)
From: root@bpl (Cron Daemon)
To: user1@bpl
Subject: Cron <user1@bpl> $PHP $ARTISAN transaction:verify >> $LOGS 2>&1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <PHP=/usr/bin/php>
X-Cron-Env: <ARTISAN=/var/www/html/artisan>
X-Cron-Env: <LOGS=/var/www/html/storage/logs/cron.log>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/user1>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=user1>
Message-Id: <20200303143001.3264910126D@bpl>
Date: Tue,  3 Mar 2020 14:30:01 +0000 (UTC)

/bin/sh: 1: cannot create /var/www/html/storage/logs/cron.log: Permission denied

Permissions of folder logs looks like:

user1@bpl:/var/www/html/storage$ ls -al
total 20
drwxrwxr-x  5 www-data www-data 4096 Feb 24 14:36 .
drwxr-xr-x 13 www-data www-data 4096 Feb 29 02:06 ..
drwxrwxr-x  3 www-data www-data 4096 Feb 28 15:13 app
drwxrwxr-x  6 www-data www-data 4096 Feb 24 14:36 framework
drwxrwxr-x  2 www-data www-data 4096 Mar  3 14:02 logs

Task Transaction verify is from cron. This task is added to the user cron. How to enable writting these logs to this file?


Since the directory permissions allow writing (file creation) for the owner and group, add yourself to the www-data group with

sudo adduser $USER www-data

The new group membership will take effect at the next login.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.