0

I am having some issues setting up django-crontab in my django project. I have followed the instructions given on the official documentation :- https://pypi.python.org/pypi/django-crontab

I have defined my cron.py under an app named ciscoaci. So its location is project/ciscoaci(which is the app)/cron.py. Inside cron.py, is a function named sshpostGetMACIP_scheduler(). I have defined 'django_crontab' under my settings.py in INSTALLED_APPS.

CRONTAB_COMMAND_SUFFIX = '2>&1'
CRONJOBS = [
    ('*/1 * * * *', 'ciscoaci.cron.sshpostGetMACIP_scheduler', '>> /axphome/xxx/netadc/ciscoaci/tmp/scheduled_job.log'),
]

Nothing shows up in my logs. I have also tried changing /axphome/xxx/netadc/ciscoaci/tmp/scheduled_job.log to ciscoaci/tmp/scheduled_job.log and it doesn't work.

Also when I do crontab -l, the cron shows up.

*/1 * * * * /root/.venvs/netadc/bin/python /home/xxx/netadc/manage.py crontab run 4a2a96ea204eb26917961a9946493f0d >> /axphome/xxxx/netadc/ciscoaci/tmp/scheduled_job.log 2>&1 # django-cronjobs for netadc

But nothing shows up in my logs. Any help would be appreciated. I do not want to use celery at this point as this is used for a temporary feature in my project.

Sindhujit
  • 51
  • 9

3 Answers3

0

You can do that using django-q. You have the scheduler directly in the admin and is easier to setup than django-crontab moreover doesn't involve your system crontab but is directly stored in your db.

Karim N Gorjux
  • 2,880
  • 22
  • 29
0

I think the logs took some time, or may be i did not add the cron-tab add command again. It's working fine now.

Sindhujit
  • 51
  • 9
0

try this CRONJOBS = [ ('*/1 * * * *', 'ciscoaci.cron.sshpostGetMACIP_scheduler', '>>'+ os.path.join(BASE_DIR, 'data.log'), ]

Arun
  • 3,440
  • 1
  • 11
  • 19