birdietorerik's avatar

Strange error

Hi all!

Have this Job, that are working fine localy but not on server

Here is my Job-file

The error on my server

Error say that it somthing to do with permission, but cant figer it out

Please help

0 likes
12 replies
birdietorerik's avatar

Hi! Solved this myself, running:

sudo chmod -R ugo+rw storage
1 like
birdietorerik's avatar

Hi All!

This is very very strandge. When i run this command on my server.

sudo chmod -R ugo+rw storage

Its working fine, but next day i must run this command again ???? What is the problem ? How can i fix this ?

rudolfbruder's avatar

Isn't it due to the fact that the chmod is applied only on already existing files? Next day new file is created and with predefined permission where laravel cannot write (append) maybe.

Snapey's avatar

You probably have a cronjob that runs as YOUR user account. Any scheduled tasks after midnight will probably cause a new log file to be created and owned by YOU.

The web server process (usually www-data) comes along later and cannot access the log file and cannot create one.

For this reason, I always make sure that;

  • crontab is owned by www-data by creating it with crontab -e -u www-data. after making sure to remove the crontab running in your account

  • make sure your user account is in the www-data group

birdietorerik's avatar

@Snapey Hi! Not so good at this, but the issue regarding storage was working fine 2 weeks ago Please help me fix this.

My cronjob file noe is:

* * * * * php8.1 /home/forge/app.easyflow.golf/current/artisan schedule:run >/dev/null 2>&1
birdietorerik's avatar

Hi!

This is a very strange error.

Have this scedule :

This is Logging to logfile. No problem

But my Log in Jobfile, i get error

"/home/forge/test.easyflow.golf/releases/20241210102605/storage/logs/laravel-2024-01-02.log" could not be opened in append mode: Failed to open stream: Permission denied

After remove Log in Jobfile, its working fine

My supervisorfile is this:

[program:second_job]
command=php8.1 /home/forge/test.easyflow.golf/current/artisan queue:work --queue="second_job_queue" --sleep=10 --daemon
process_name=%(program_name)s_%(process_num)02d
autostart=true
autorestart=true
user=forge
numprocs=5
stdout_logfile=/home/forge/.forge/second_job.log
stdout_logfile_maxbytes=15MB 
stdout_logfile_backups=3

Error somting to do with user=forge ?

JussiMannisto's avatar

@birdietorerik Check who owns the file laravel-2024-01-02.log.

Most likely, you've run Artisan commands as some user other than forge, either from the command line or through cron tasks. When the log file gets created, it's owned by that user, which prevents forge from writing to it.

birdietorerik's avatar

@JussiMannisto Hi! Crontab calls ->

* * * * * php8.1 /home/forge/app.easyflow.golf/current/artisan schedule:run >/dev/null 2>&1

Posibble to set user to forge here ?

Snapey's avatar

are you talking about a queued job or a scheduled command? Your post is confusing.

birdietorerik's avatar

Hi all!

Sorry, my mistace...

Sceduled command is calles from crontab and there i have Log that are working fine

Log in queued job is called from my supervisor. And this is using user=forge.... and give me purmission problem with Log file

Snapey's avatar

@birdietorerik so you need to ensure they are both using the same user account, or are on the same group, and the file is group writeable

Please or to participate in this conversation.