问题
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