backtrack
backtrack

Reputation: 8154

celery schedule not working

I am using celery and trying to run the corntab. Below is my celery.py

from __future__ import absolute_import
from celery.schedules import crontab


from celery import Celery

app = Celery('Celery_1',
             broker='amqp://test:test@localhost//',
             include=['Celery_1.tasks'])

# Optional configuration, see the application user guide.
app.conf.update(
    CELERY_TASK_RESULT_EXPIRES=3600,
    CELERYBEAT_SCHEDULE = {
    'T1': {
        'task': 'Celery_1.tasks.add',
        'schedule': crontab(minute='*/1'),
        'args': (4, 5)
}
},
    CELERY_IMPORTS = ('Celery_1.tasks', )

)

if __name__ == '__main__':
    app.start()

And my tasks.py

from __future__ import absolute_import

from Celery_1.celery import app


@app.task(name='Celery_1.add')
def add(x, y):
    return x + y

when i schedule by celery beat

enter image description here

but it is not running task for every minute. Can any one please help me ?

Upvotes: 0

Views: 1499

Answers (1)

sourya
sourya

Reputation: 165

You should run it this way (while still in the Celery_1 directory):

echo $null >> __init__.py #to make your directory a python project cd .. celery -A Celery_1 beat

Celery_1 is the name of your app.

Upvotes: 1

Related Questions