I am setting up my first cron job and it does not work. I think the problem may be a relative path problem.
Cron task:
*/1 * * * * python2.7 /home/path/to/my/script/my_script.py
and my_script.py:
import sqlite3 db = sqlite3.connect('my_db.db') cur = db.cursor() ...
How to make sure my_script.py looks for my_db.db in /home/path/to/my/script/ (the same directory where my_script.py is located) and that no crontab directory exists?
Other troubleshooting suggestions are also welcome.
Note. I think the problem may be a path problem, because when I try to run my_script.py using python2.7 /home/path/to/my/script/my_script.py from any location other than /home/path/to/my/script/ , I get an error "cannot open database".
python cron crontab
Brian goler
source share