How to use Tivix django-cron app
Asked Answered
T

1

5

I got exact same problem described in this post, but the answer doesn't help at all. In short, I am using Tivix django-cron, the cron job is not running at regular basis.

To illustrate the problem, the following cron job class is intended to send email every min once running runcrons command. But in fact, it only sends out one email and no more. That defeats the purpose of cron... What am I missing?

class TestCron(CronJobBase):
    schedule = Schedule(run_every_mins=1)
    code = 'test_cron_philip'

    def do(self):
        send_mail('cron test', 'body is test body', '[email protected]',
                  ['[email protected]'],fail_silently=False)
Teel answered 15/7, 2013 at 0:25 Comment(0)
B
8

Yes, you miss something ("runcrons" is not background deamon). From documentation:

"Now everytime you run the management command python manage.py runcrons all the crons will run if required. Depending on the application the management command can be called from the Unix crontab as often as required. Every 5 minutes usually works for most of my applications."

That means you have to put "runcrons" command in your crontab.

Example:

You have some CronJob that do something every 30 min.

To get this running you must edit you crontab (linux, mac) or task scheduler (windows) to run "python manage.py runcrons" for every, let say 1 min.

If you get this running, your CronJob will be pinged every 1 min and run if necessary (every 30 min or whatever value you have set).

Hope this helps.

Bristow answered 15/7, 2013 at 7:43 Comment(1)
i had this in my crontab file:* * * * * root python /home/nash/djangocode/zingyhomes_new/manage.py runcrons but it still does not works out ? please help .Nicias

© 2022 - 2024 — McMap. All rights reserved.