Python脚本未在crontab中执行 [英] Python script not executing in crontab

查看:59
本文介绍了Python脚本未在crontab中执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图让我的服务器每小时执行一次Python脚本.

So I'm trying to have my server execute a Python script every hour.

当我进入目录并使用python twitter.py运行它时,它工作正常.

When I go into the directory and run it with python twitter.py, it works fine.

但是,我在crontab中有此条目,但它不起作用:

However, I have this entry in crontab and it doesn't work:

0 * * * * /run/twitterparse/twitter.py > /run/twitterparse

我试图让它每小时执行一次.

I am trying to have it execute every hour, on the hour.

以下是系统日志的输出:

Here's the output to the syslog:

Aug 5  13:00:01 localhost CRON[11474]: (root) CMD (/run/twitterparse/twitter.py >/run/twitterparse/)

Aug 5  13:00:01 localhost CRON[11473]: (CRON) info (No MTA installed, discarding output)

现在应该做的是访问数据库并将信息从Web保存到该数据库.手动运行但不自动运行时,该脚本可以达到很好的效果.

Now what it should be doing is accessing a database and saving information from the web to that database. The script does that fine when run manually, but not automatically.

推荐答案

我通过这样做解决了问题

I fixed my problem by doing this

0 * * * * python /run/twitterparse/twitter.py > /run/twitterparse

并且py文件应该是可执行文件

and the py file should be executable

chmod +x twitter.py

这篇关于Python脚本未在crontab中执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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