Reputation: 306
I have a python script which I want to run on a daily basis. I'm using crontabs for this on my Mac with the following command:
*/1 * * * * /opt/anaconda3/bin/python *absolute_path*/dynamic_dataset.py
It is working fine! But the log shows that I am running into a "FileNotFoundError". I am reading a csv and h5 file in which are not found. How can I make crontab also use these files?
Many thanks in advance! 😊
Upvotes: 0
Views: 122
Reputation: 1303
You don't know in which working folder is executed your program. I recommand using such a line:
*/1 * * * * cd /path/to/your/working/dir && /opt/anaconda3/bin/python dynamic_dataset.py
Upvotes: 0
Reputation: 306
I found the problem myself. For python to find the other files you have to execute the python in the directory of the files. So what I did is to navigate to the directory in the cronjob first.
*/1 * * * * cd *path*/Local && /opt/anaconda3/bin/python *path*/Local/dynamic_dataset.py
Upvotes: 1