CRON doesn't run tasks because "/bin/bash: /var/log/cron.log: Permission denied"
16,378
Looks like it can't create the log file. Check the permissions of /var/log folder. It should be
ls -l /var/
drwxrwxr-x 18 root syslog 4096 Mar 6 14:30 log
If it doesn't look like the first starting with the drwxrwxr-x, change the permissions to the folder by typing in the following:
sudo chmod 775 /var/log
Run the cron job again.
Related videos on Youtube
Comments
-
user984621 almost 2 years
I have the following CRON task:
MAILTO="[email protected]" # Begin Whenever generated tasks for: projectname 30 4 * * * /bin/bash -l -c 'cd /home/deployer/apps/project_production/releases/20150305135322 && bin/rails runner -e production '\''Invoices.run_update'\'' >> /var/log/cron.log 2>&1' # End Whenever generated tasks for: projectname
But when I take a look on the report that is sent to my email address from the server, there's just following:
/bin/bash: /var/log/cron.log: Permission denied
(the path to the log file is proper)
Which permissions do I have to set for log files of CRON jobs?
Thank you, have a nice day.
EDIT: there is no
cron.allow
orcron.deny
file in the/etc
directory.EDIT2; Tried
sudo chmod u+w cron.log
, but still the same.-
steeldriver over 9 yearsHow did you create the cron task? as a user crontab (
crontab -e
) or as a root crontab (sudo crontab -e
)? -
user984621 over 9 yearsThe CRON tab was created by a gem from Ruby on Rails. The Rails application use the user called
deployer
.
-
-
user984621 over 9 yearsHi Terrance, thank you for your message. The file is in the directory
/var/log
. The permissions:-rw-r----- 1 syslog adm 25621 Mar 6 22:17 cron.log
. I also testedcat cron.log
and got this:cat: cron.log: Permission denied
. -
Terrance over 9 yearsChange the permissions of the file to match. There may be a change that adm is not running the cron job.
sudo chmod 660 /var/log/cron.log
-
Terrance over 9 yearsOr just open up the file so everything can write to it.
sudo chmod 666 /var/log/cron.log
-
Alexander over 9 yearsOr run
chown <userThatRunsTheCronJob> /var/log/cron.log
- e.g.chown deployer:deployer /var/log/cron.log
-
user984621 over 9 yearsThank you guys! Now, I can
cat
the file, let's see tonight if the CRON task will be proceeded.