我寫好的一個python腳本,通過crontab定時執行,但是卻不成功
10 2 * * * python /home/ztx/growingio_funnels/readfunnels.py
最後通過在網上查看發現可能是路徑問題。
路徑分爲絕對路徑和相對路徑,如果在profile文件中沒有配置,直接寫python會默認到/usr/bin/python,初裝的python版本爲2.X。但是我是用python3寫的。也安裝了anaconda3。
通過whereis python找到路徑,加上路徑
23 11 * * * /root/anaconda3/bin/python /home/ztx/growingio_funnels/readfunnels.py
成功了。
開發世界的小門道還是挺多的,需要多多注意。