spac3_monkey
spac3_monkey

Reputation: 130

Periodic task not working when using crontab at given hour and minute

I'm trying to run a periodic task defined in a simple python script:

@periodic_task(run_every=crontab(hour=7, minute=43))
def every_day_morning():
    print("Good Morning!")

This is the command line I'm using:

python -m celery -A tasks beat

When I use crontab(minute='*') it works perfectly but, when I try it like:

@periodic_task(run_every=crontab(hour=7, minute=43))

it doesn't work (the task doesn't run).

I'm using python 2.7, and celery 3.1.16 in Windows 8.1.

Upvotes: 4

Views: 2680

Answers (2)

PKD
PKD

Reputation: 194

Check your timezone by running command in terminal

timedatectl | grep "Timezone"

Update your celery app configuration

app = Celery()
app.conf.update(timezone='Asia/Kolkata')  # set your time zone here

Hope this helps

Upvotes: 0

n3xtm3
n3xtm3

Reputation: 58

check your timezone! utc0 is celery default timezone!

U need to change it to your system timezone, like this:

pp = Celery(...)
app.conf.update(...
        CELERY_TIMEZONE = 'Asia/Shanghai'   # set timezone in here
        )

Upvotes: 4

Related Questions