Forums

Permission Issues in Scheduled Tasks

Hi all, I'm new to Pythonanywhere. I've just set up my project on the cloud. It runs smoothly through the console (python 2.7). When I scheduled the same file to be run daily it gives me permission error "OSError: [Errno 13] Permission denied: '../directory'". But the same script is running fine manually through the consolle... How can I fix this?

Thanks

The scheduled task is probably starting in a different current directory?

Actually I don't know...How I can I check it? The permission issues on the directory x occurs when the script start writing files on that directory x.

One simple way is to write a Bash shell file to set the current directory ('cd' command) and then run your file.

Then setup the Scheduled task to run the Bash file, rather than your prog directly.

Ok I wrote a file in the form:

python /home/mypath/myscripy.py

and save it as bash.sh.

Then run it in the scheduled page...

but nothing happens.

Thanks for your support!

You need a 'hash + bang' as the first line of your Bash file, see for example:

https://www.pythonanywhere.com/forums/topic/787/#id_post_5597

If still no luck, maybe a PA person could have a look ?

Ok fixed! The problem was indeed related to the Scheduler working path. I've now set up my files correctly and it works! Thanks again for your support!

;----)