[英]Crontab (Centos7) with Python Files
I would like to get help regarding Crontab on Centos 7. 我想获得有关Centos 7上Crontab的帮助。
I Need to create the scheduler to run python script (which have 2-5 addition import in the same folder) by using Crontabs 我需要使用Crontabs创建计划程序以运行python脚本(在同一文件夹中具有2-5个附加导入)
Currently, my crontab looks like this I have 目前,我的crontab看起来像这样
PATH = /srv/git/XXX
30 * * * * cd $PATH/XXX/XXXX python $PATH/XXX/XXXX/upload.py
I have tried to use a path to the python folder and so on, nothing works. 我试图使用python文件夹的路径,依此类推,没有任何效果。 Then I found that the best way is to use .sh files.
然后我发现最好的方法是使用.sh文件。
WHAT I NEED: Currently, I'm looking to for the best way to run crontab scheduler, for python script(which have an extra import in the same folder) with PROD and DEV variables for future testings. 我需要什么:目前,我正在寻找运行crontab调度程序的最佳方法,以用于带有PROD和DEV变量的python脚本(在同一文件夹中有额外的导入),以供将来测试。 Any better way instead of .sh files?
还有什么更好的方法来代替.sh文件? and is .sh is the best way, what if the clean way to write them?
.sh是最好的方法吗,如果使用干净的方法编写它们怎么办?
I would create a *.sh (eg dum.sh) file like this: 我将创建一个* .sh(例如dum.sh)文件,如下所示:
#!/bin/bash
export PATH = /srv/git/XXX
python $PATH/XXX/XXXX/upload.py
and in my Crontab file use: 并在我的Crontab文件中使用:
30 * * * * /.../dum.sh
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.