Trouble running python script with cron


#1

Hey all,
I am trying to run a python script using cron. It runs flawlessly when I run it from the command line, eg: python path/to/file/myscript.py. However, if I set up a cron job, eg: /2 * * * * python path/to/file/myscript.py it will not run. I have made the script executable and changed permissions. The next thing I can think of is to have cron run a bash script that opens the python script, but that seems unnecessary. Any insights would be appreciated!


#2

Update:
I created a bash script to run the python script and I am having the same problem. I can execute the bash script just fine, but cron fails to execute it.


#3

Check to see which “user” cron is using to run your script. If the user that cron is running as doesn’t have permission or access, then it won’t run. cron won’t necessarily run using your username.