如何设置一个 cron 来专门与 python3 一起运行? [英] How do I setup a cron to run specifically with python3?

查看:57
本文介绍了如何设置一个 cron 来专门与 python3 一起运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个 cron 作业来每小时运行一个 python 脚本,但它必须使用 python3 运行.

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

我尝试将 cron 设置为指向 python 3.6 库,但这似乎不起作用.

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

我是这样设置的

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

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.

推荐答案

你确定你的 python3 路径是正确的吗?如果您没有使用虚拟环境,您可以试试这个:

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

此外,您可以手动运行 which python3 来验证您的 python3 路径.

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

这篇关于如何设置一个 cron 来专门与 python3 一起运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆