简体   繁体   English

cron python文件在centos 7上不起作用

[英]cron python file doesn't work on centos 7

i'm trying to schedule my pythohn script into Centos 7 with cron. 我正在尝试将我的pythohn脚本与cron一起安排到Centos 7中。 On my script at start i have added this: 在开始的脚本中,我添加了以下内容:

#!/usr/local/bin/python

and this is my cron file that i have create into folder that contain python file 这是我创建到包含python文件的文件夹中的cron文件

*/5 * * * * /usr/local/bin/python /home/Documents/SCRAPE_PYTHON/SCRAPE.py &>> /home/Desktop/log.txt

i have try to run the script into terminal by chmod +x and works fine. 我已经尝试通过chmod + x将脚本运行到终端中,并且工作正常。 But whit this configuration when in terminal i set crontab .cron the job doesn't work. 但是在终端中我设置crontab .cron时使用这种配置,该工作无法正常工作。 The log file set into cron file are not write and script not run. 设置为cron文件的日志文件未写入,脚本未运行。 The script could be write some data into db and the db is always empty. 该脚本可以将一些数据写入db,并且db始终为空。 Any help??? 有帮助吗??? Thanks 谢谢

Type crontab -e in the shell, this will open the cron editor. 在外壳程序中键入crontab -e ,这将打开cron编辑器。 Here copy paste the entire command. 在这里复制粘贴整个命令。

*/5 * * * * /usr/local/bin/python /home/Documents/SCRAPE_PYTHON/SCRAPE.py &>> /home/Desktop/log.txt

Now press Esc key then type colon :wq! 现在按Esc键,然后输入冒号:wq! and press Enter key. 然后按Enter键。 This will install your cron. 这将安装您的cron。 Your cron should run every 5 minutes. 您的cron应该每5分钟运行一次。

Your standard output and error will be appended to /home/Desktop/log.txt . 您的标准输出和错误将附加到/home/Desktop/log.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM