使用crontab/cron计划python 3.6脚本 [英] Scheduling a python 3.6 script in using crontab/cron

查看:88
本文介绍了使用crontab/cron计划python 3.6脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在Cent OS开发服务器上设置cron标签/作业.

I'm just setting up a cron tab/job on my Cent OS developement server.

在我的crontab中,我有以下内容. (忽略时间设置,此时间大约是在UTC服务器时间15:32处添加的,只是为了让下一个计划的运行时间生效.)

Within my crontab I have the following. (Ignore the time setting, this was added about 15:32 UTC server time just to get the next scheduled run in).

34 15 * * * cd welcomeclient-0.0.5 && python3.6 main.py

在命令行中cd welcomeclient-0.0.5 && python3.6 main.py正常工作. welcomeclient-0.0.5在液滴的根下,而python3.6/usr/bin中.

In the command line cd welcomeclient-0.0.5 && python3.6 main.py works fine. welcomeclient-0.0.5 is under root in the droplet, and python3.6 is in /usr/bin.

有什么建议吗?

推荐答案

尝试在crontab命令中使用绝对路径:

Try using absolute paths in your crontab command:

34 15 * * * cd /foo/bar/welcomeclient-0.0.5 && /usr/bin/python3.6 main.py

或者,假设main.py也没有使用其中的相对路径:

or, assuming the main.py does not also make use of relative paths inside of it :

34 15 * * */usr/bin/python3.6 /foo/bar/welcomeclient-0.0.5/main.py

这篇关于使用crontab/cron计划python 3.6脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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