cron python文件在centos 7上不起作用 [英] cron python file doesn't work on centos 7

查看:122
本文介绍了cron python文件在centos 7上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用cron将pythohn脚本安排到Centos 7中。
在开始时,我在脚本中添加了以下内容:

i'm trying to schedule my pythohn script into Centos 7 with cron. On my script at start i have added this:

#!/usr/local/bin/python

这是我的cron文件,我已将其创建到包含python文件的文件夹中

and this is my cron file that i have create into folder that contain python file

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

我尝试通过chmod + x将脚本运行到终端中并且工作正常。
但是在终端中我将crontab设置为.cron时,此配置无效。设置为cron文件的日志文件未写入,脚本未运行。该脚本可以将一些数据写入db,并且db始终为空。
任何帮助吗???
谢谢

i have try to run the script into terminal by chmod +x and works fine. But whit this configuration when in terminal i set crontab .cron the job doesn't work. The log file set into cron file are not write and script not run. The script could be write some data into db and the db is always empty. Any help??? Thanks

推荐答案

在shell中键入 crontab -e ,这将打开cron编辑器。在这里复制粘贴整个命令。

Type crontab -e in the shell, this will open the cron editor. Here copy paste the entire command.

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

现在按 Esc 键,然后键入冒号:wq!并按 Enter 键。这将安装您的cron。您的cron应该每5分钟运行一次。

Now press Esc key then type colon :wq! and press Enter key. This will install your cron. Your cron should run every 5 minutes.

您的标准输出和错误将附加到 /home/Desktop/log.txt 中。

Your standard output and error will be appended to /home/Desktop/log.txt.

这篇关于cron python文件在centos 7上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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