/ / cron não dispara em intervalos regulares - django, cron, crontab

cron não disparando em intervalos regulares - django, cron, crontab

Eu quero definir um cron que busca algumas históriasde uma API a cada 5 minutos e envie uma mensagem se surgirem novas histórias. Aqui está o meu arquivo crontab. (Utilizou um comando de gerenciamento do django para fazer isso). Disparei o comando de gerenciamento e ele me enviou as informações corretas, mas quando estou tentando definir um cronjob para o mesmo, não está disparando. Aqui está o meu arquivo 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

Aqui está a sua permissão

ls -l /etc/crontab
-rw-r--r-- 1 root root 884 Aug 17 20:20 /etc/crontab

Também não consigo ver nenhum aviso e erro no arquivo 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)

Eu também tentei reiniciar o crontab e reiniciar meu computador. Mas não consigo corrigir esse problema.

Respostas:

1 para resposta № 1

A sintaxe correta para execução a cada 5 minutos seria

*/5 * * * * root /home/anurag/projects/virtualenvs/django6/bin/python /home/anurag/Documents/HNStories/hnstories/manage.py get_stories >> /home/anurag/cron_log.txt

Outro motivo pelo qual o comando não está sendo executado pode ser uma nova linha ausente no final de /etc/crontab

EDITAR: Você também pode querer examinar django-extensions que fornece uma extensão de comando (runjobs) para executar tarefas agendadas.