I need to run a cron job on a python script to generate basemap plots.
The script by itself runs ok manually.
A simple
print("Hello")
at the start of the program with the rest commented out also runs ok on cron with
*/10 * * * * /usr/bin/python3 ~/PythonFiles/TestScript.py > /dev/null 2>&1 >>log.txt
I made the file an executable using chmod +x
and added a shebang (#!/home/usr/anaconda3/bin/python
) at the start of the program. I can monitor activity in the log file via a printed message at the start of the program too
- When I come to run the "normal" program which includes modules (
urllib.request, datetime, matplotlib, basemap, pygrib, numpy, ...
), the script then stops outputting anything to log.txt
So I suspect it is to do with modules and possibly their locations. I checked and they seem to have been installed in various places (.../pkgs, .../conda-meta, .../site-packages
, etc...)
First of all, is what I suspect correct?
Secondly, how do I fix it so that cron knows where to find all the libraries to run the job?
Many thanks!