Python executes manually, fails on Cron Scheduler
-
Hey all,
Had a cron job (python script) running just fine yesterday; today not so good. I can execute the python program just fine manually, however it will not execute through the cron scheduler. My crontab entry is (with quotes removed):
"#
"* * * * * python /root/TempMonitor/TempMonitor.py
"#I also tried:
"#
"* * * * * /usr/bin/python /root/TempMonitor/TempMonitor.py
"#Any ideas what happened?
Thanks,
Nick
-
Well....I'm gonna need a beer when I get home.
I was using a JSON file to store data from the script. I don't know why it took me so long to do this, but I included the logging for the script in cron and an error was generated indicating that it could not find my JSON. It appears when running the Python script from the shell, it must use the working directory. I included the full path in my script and it works now.
Though, I have no idea what changed from yesterday to today...
Tip of the Day: Use the logs to help diagnose an issue. They are terribly useful.