Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>Running Periodic Tasks</h3> <p>I'm not sure what you've tried so far, or what your <code>settings.py</code> file looks like but here are some ways to get djcelery to run scheduled tasks.</p> <p>1) In your <code>tasks.py</code>, create a task and use the <code>celery.decorators.periodic_task</code> decorator. e.g.</p> <pre><code>from celery.task.schedules import crontab from celery.decorators import periodic_task @periodic_task(run_every=crontab(hour=”*”, minute=”*”, day_of_week=”*”)) def a_periodic_task(): print “Hello World!” </code></pre> <p>or</p> <pre><code>@celery.decorators.periodic_task(run_every=datetime.timedelta(minutes=5)) def a_periodic_task(): print “Hello World!” </code></pre> <p>2) In your <code>celery.conf</code> file use the <code>CELERYBEAT_SCHEDULE</code> setting like so:</p> <pre><code>from datetime import timedelta CELERYBEAT_SCHEDULE = { "runs-every-30-seconds": { "task": "tasks.add", "schedule": timedelta(seconds=30), "args": (16, 16) }, } </code></pre> <p>You can read more about this in the <a href="http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html" rel="nofollow">periodic task documentation</a>.</p> <p>Though please remeber that you must start celery in <a href="http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#starting-the-scheduler" rel="nofollow">beat mode</a> by:</p> <pre><code>python manage.py celeryd -B </code></pre> <p>And also check you've done all the <a href="https://pypi.python.org/pypi/django-celery" rel="nofollow">installation steps</a> including adding <code>djcelery</code> to your <code>INSTALLED_APPS</code> and running <code>python manage.py syncdb</code> (or <code>python manage.py migrate djcelery</code> if you're using south)</p> <h3>Deployment</h3> <p>The <a href="http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html" rel="nofollow">celery documentation</a> has a great section on daemonising your celery processes for deployment including an <a href="http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#generic-initd-celerybeat-django-example" rel="nofollow">example django configuration for beat mode</a>.</p> <p><strong>From the Docs:</strong></p> <blockquote> <pre><code># Where the Django project is. CELERYBEAT_CHDIR="/opt/Project/" # Name of the projects settings module. export DJANGO_SETTINGS_MODULE="settings" # Path to celerybeat CELERYBEAT="/opt/Project/manage.py celerybeat" # Extra arguments to celerybeat CELERYBEAT_OPTS="--schedule=/var/run/celerybeat-schedule" </code></pre> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload