【发布时间】:2014-08-17 23:13:01
【问题描述】:
我想设置一个 cron,每 5 分钟从 api 获取一些故事,并在出现任何新故事时发送邮件。这是我的 crontab 文件。 (使用 django 管理命令来执行此操作)。我触发了管理命令,它向我发送了正确的信息,但是当我尝试为它设置一个 cronjob 时,它没有触发。这是我的 crontab 文件
vi /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
5 * * * * root /home/anurag/projects/virtualenvs/django6/bin/python /home/anurag/Documents/HNStories/hnstories/manage.py get_stories >> /home/anurag/cron_log.txt
这是它的许可
ls -l /etc/crontab
-rw-r--r-- 1 root root 884 Aug 17 20:20 /etc/crontab
我也无法在 syslog 文件中看到任何警告和错误
cat /var/log/syslog | grep crontab
Aug 17 12:58:01 anurag cron[1257]: (*system*) RELOAD (/etc/crontab)
Aug 17 17:24:01 anurag cron[8534]: (*system*) RELOAD (/etc/crontab)
Aug 17 20:21:01 anurag cron[1139]: (*system*) RELOAD (/etc/crontab)
我还尝试重新启动 crontab 并重新启动我的计算机。但我无法解决此问题。
【问题讨论】:
-
cat /var/log/syslog | grep cron给你什么?有什么错误吗?