How do I setup a cron to run specifically with python3?

喜夏-厌秋 提交于 2019-12-24 23:07:13

问题


I'm trying to setup a cron job to run a python script every hour, but it has to be run with python3.

I've tried setting up the cron to point to the python 3.6 libraries, but this doesn't seem to work.

This is how I've set it up

0 * * * * /usr/local/lib/python3.6/python3 /mnt/dietpi_userdata/python/main.py

I suspect it's something simple, but it's beyond my own (googling) skills.


回答1:


Are you sure that your python3 path is correct? If you are not using a virtual environment you could try this:

0 * * * * $(which python3) /mnt/dietpi_userdata/python/main.py

Additionally you could manually run which python3 to verify your python3 path.



来源:https://stackoverflow.com/questions/57894681/how-do-i-setup-a-cron-to-run-specifically-with-python3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!