Closed cis-yogesh closed 10 years ago
You're fundamentally misunderstanding how this library works.
runcrons
is a command that, when executed once, will loop over your CRON_CLASSES
list and determine if each cron needs to be run once, right now.
You need to invoke runcrons
yourself via the actual crontab.
I do that in my projects with this crontab:
* * * * * /path/to/crons.sh >> /var/logs/cronjobs/crons.log 3 >> /var/logs/cronjobs/cron_errors.log
Where cron.sh
has open permissions and looks like this:
#! /bin/bash
source /path/to/virtualenvs/mysite/bin/activate
python /var/www/mysite/manage.py runcrons
deactivate
Be sure to activate some type of caching engine, as that is what django_crons
uses to enforce the ALLOW_PARALLEL_RUNS
setting value. I use simple DB caching for this.
Thanks @craiglabenz , I am gone according to your instructional and My crones are start running .
Hello All,
I have written code according to documentation. My setting file is CRON_CLASSES = [ "cronapp.cron.MyCronJob", "django_cron.cron.FailedRunsNotificationCronJob" ] INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_cron', )
My cron.py file is within my app directory from django_cron import CronJobBase, Schedule class MyCronJob(CronJobBase): RUN_EVERY_MINS = 10 schedule = Schedule(run_every_mins=RUN_EVERY_MINS) code = 'cronapp.MyCronJob' # a unique code
and first time when i am going to run command "python manage.py runcrons" code is executed. after that this code not executed every 2 min. I am going to setup cron job first time can you please let me know. what i am doing wrong. Regards Yogesh D