Closed hunanboy closed 11 years ago
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.
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.
This is like creating cron job on top of another cron job.
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
Link to the SO question, for posterity?
I don't understand the point of setting schedule in django-cron, If we are setting it using the windows task scheduler.
@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.
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'