0

I've got a cronjob that triggers a python script. The python script creates files a new log file each time it runs and writes what its doing into these files. It also dumps data in .json format in a specific directory. When I list the files and folders associated with the python script, including the directory it needs to write to, I can see that my user account is the owner. The cronjob is also owned by me inasmuch as its my user accounts crontab. The cronjob runs fine but it wont create or write the log files or the .json files. I suspect its a permissions issue. All the files are chmod 775. I don't want to make it 777 as this is a security risk.

I've ran the python script for several weeks on my local machine and it all works fine. Its only on the server where it's having issues. My account on the server is a sudo account so I'm not sure what the issue is. It's an ubuntu server. Anyone had this issue and recommend a fix without making the directory 777?

1 Answer 1

1

I figured it out. It's not to do with permissions, its to do with file paths. When running the script manually from the command line specifying a relative path to a file or directory in the python script works. However this does not seem to work when its ran with Cron. Once I modified the code, changing relative file paths to absolute file paths the script was able to create and modify files and directories.

I'll leave this here in case anyone else has a similar issue.

You must log in to answer this question.

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