I'm working on a python script, I created a file in /var/log/ folder with 664 permissions

python script is not able to write logs to the file created, IDK why... since file owner is ubuntu(aws's default user).

very carefully I have given Read and Write permission to the file

scheduled crontab failed to run the app because of permission denied issue. Any ideas?

i) the command you used to set up the crontab - crontab -e ii) the crontab line that is running the python script - */30 * * * * python3 /home/ubuntu/message_initiator.py iii) the exact error message - Permission denied: '/var/log/ice-message-initiator.log'

  • can the owner travel the directories below?
    – pLumo
    Mar 31, 2020 at 11:22
  • yes, I can go inside any folder and see the content. Mar 31, 2020 at 11:24
  • 1
    Please edit your question and include: i) the command you used to set up the crontab, ii) the crontab line that is running the python script and iii) the exact error message.
    – terdon
    Mar 31, 2020 at 11:37
  • added more details for clarity in question. Apr 1, 2020 at 7:41
  • @epsan Who is the cronjob running as? The ubuntu user? Apr 1, 2020 at 7:49

1 Answer 1


If you run

ll -d /var/log

Then you'll see that it is owned by root (possibly with syslog as the group) and has 755 or 775 permissions which means that while others can read and traverse the directory, only root (and possibly syslog) can modify it. ice-message-initiator.log is in /var/log and while ubuntu is its owner, ubuntu doesn't have modify permissions to /var/log which means that it can't modify its contents whether they are files or directories. The error isn't occurring because the ubuntu user can't read the file but because it can't write to the file due to not having modify permissions to its parent directory, /var/log.

To have your cronjob work, you either need to either run it as root or have it write the log file into a subdirectory such as /var/log/ice and give ubuntu modify permissions to it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .