9

I'm finding that celerybeat is using UTC time in its scheduling (and outputting logs in UK time?!) even though I believe I have the required settings in my django settings.py:

TIME_ZONE = 'UTC'
USE_TZ = True
CELERY_ENABLE_UTC = True
CELERY_TIMEZONE = 'Australia/Sydney'
CELERYBEAT_SCHEDULE = 
    "testRunBeat" : {
        "task" : "experiments.tasks.testHeartBeat",
        "schedule" : crontab(minute = "*/1", hour="13-14"),    
}

I have tried switching the TIME_ZONE variable with no luck

I am using:

django==1.4
celery==2.5.5
django-celery==2.5.5

Thanks

Trent
  • 2,328
  • 3
  • 33
  • 51

2 Answers2

6

Turns out that it was a bug in celery which is now fixed. See https://github.com/celery/django-celery/issues/150

Trent
  • 2,328
  • 3
  • 33
  • 51
4

I think that you want

CELERY_ENABLE_UTC = False

The celery configuration docs state pretty clearly that if this value is true, dates and times are converted to UTC. Also note this value is enabled by default since version 3.0.

Javier Enciso
  • 55
  • 1
  • 2
  • 11
Mark Chackerian
  • 21,866
  • 6
  • 108
  • 99
  • Hi. The doc says: "If enabled dates and times _in messages_" - I'm not sure exactly what the scope of that, but it doesn't necessarily mean that crontab entries for celerybeat are in UTC. As well [here](http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#beat-entries) the docs say: "By default the current local timezone is used, but you can also set a specific timezone by enabling the CELERY_ENABLE_UTC setting and configuring the CELERY_TIMEZONE setting" with an example, implying that you need to enable UTC for _any_ specified timezone. – Trent Aug 11 '12 at 05:11
  • The documentation may be lacking or misleading, but I do know that this worked for me. I recently upgraded from 2.4.x to 3.0.x and all of my crontab entries switched from local time to UTC. Once I set CELERY_ENABLE_UTC = False all of my crontab entries went back to local time. – Mark Chackerian Aug 13 '12 at 17:12
  • My current django setup has the timezone set to UTC, so my problem is is that I'm can't get away from UTC (I'm trying to get the crontab entries to schedule of Australia/Sydney time). I'll have a closer look.. – Trent Aug 14 '12 at 13:24
  • hey please can anyone help me that i want to start the periodic task schedule at `10PM` today and this schedule of repeat at the interval of 60 seconds. then what should i do?? – Rohitashv Singhal Aug 28 '12 at 10:47