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.

Share:
16,378

Related videos on Youtube

user984621
Author by

user984621

Sell or buy the code you want. www.codestrap.com

Updated on September 18, 2022

Comments

  • user984621
    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 or cron.deny file in the /etc directory.

    EDIT2; Tried sudo chmod u+w cron.log, but still the same.

    • steeldriver
      steeldriver over 9 years
      How did you create the cron task? as a user crontab (crontab -e) or as a root crontab (sudo crontab -e)?
    • user984621
      user984621 over 9 years
      The CRON tab was created by a gem from Ruby on Rails. The Rails application use the user called deployer.
  • user984621
    user984621 over 9 years
    Hi 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 tested cat cron.log and got this: cat: cron.log: Permission denied.
  • Terrance
    Terrance over 9 years
    Change 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
    Terrance over 9 years
    Or just open up the file so everything can write to it. sudo chmod 666 /var/log/cron.log
  • Alexander
    Alexander over 9 years
    Or run chown <userThatRunsTheCronJob> /var/log/cron.log - e.g. chown deployer:deployer /var/log/cron.log
  • user984621
    user984621 over 9 years
    Thank you guys! Now, I can cat the file, let's see tonight if the CRON task will be proceeded.