Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runcrons is once-and-for-all? #21

Closed
hunanboy opened this issue Jul 15, 2013 · 7 comments
Closed

runcrons is once-and-for-all? #21

hunanboy opened this issue Jul 15, 2013 · 7 comments

Comments

@hunanboy
Copy link

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 every time I run runcrons command (instead of send one email per minute). That defeats the purpose of cron... Am I missing something?

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

def do(self):
    send_mail('cron test', 'body is test body', 'coach_zhong@163.com',
              ['admin@dessert.webfactional.com'],fail_silently=False)
@dfryta
Copy link
Member

dfryta commented Jul 15, 2013

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.

@hunanboy
Copy link
Author

Thanks I notice you have answered my question on SO as well:) Let's move over there. It might benefit more people. And may I suggest you add this answer to project wiki? It clarify things for newbies like me. I once thought the purpose of your app is to by-pass crontab entirely.

@chachra chachra closed this as completed Aug 15, 2013
@GESTIFANOS
Copy link

This is like creating cron job on top of another cron job.

@DanielStevenLewis
Copy link

I also experienced this issue until finding this ticket. Documentation could use further clarification. "everytime you run the management command python manage.py runcrons all the crons will run if required." indicates to me that manage.py runcrons starts a recurring cron job

@craiglabenz
Copy link

Link to the SO question, for posterity?

@shivamsinghal212
Copy link

I don't understand the point of setting schedule in django-cron, If we are setting it using the windows task scheduler.

@craiglabenz
Copy link

@shivamsinghal212 The idea is that your window task scheduler will invoke python manage.py runcrons very regularly -- say, every minute, or every 5 minutes. django-cron then internally maintains the schedule of your jobs, launching each as necessary. This allows you to easily keep said schedules inside your application code and thus inside version control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants