Repository: celery/celery

Issue:
Celerybeat runs periodic tasks every 5 seconds regardless of interval
I recently upgraded to celery 3 and have been experiencing some strange behavior with celerybeat, which was acting normally before the upgrade.

My environment:

python 2.7.3 
django 1.4.1
virtualenv 
django-celery 3.0.6
celery 3.0.6

Regardless of what interval I define for my periodic tasks - which I adjust through the django admin - celerybeat fires off the periodic tasks every 5 seconds. This occurs regardless of the interval. Interestingly, however, when the periodic task is set disabled, celerybeat stops sending tasks, so it must be responsive to the scheduler at some level.



Discussion:
Could you try upgrading to celery 3.0.7?  Also please delete an existing `celerybeat-schedule` file if any.

Thanks - Will try that and update later today.

On Tue, Aug 28, 2012 at 12:02 PM, Ask Solem Hoel
notifications@github.comwrote:

> Could you try upgrading to celery 3.0.7? Also please delete an existing
> celerybeat-schedule file if any.
> 
> —
> Reply to this email directly or view it on GitHubhttps://github.com/celery/celery/issues/943#issuecomment-8096911.

I'm having the same problem on 3.0.7 (django-celery 3.0.6), redis broker.  

```
from celery.task import periodic_task

@periodic_task(run_every=crontab(hour="*", minute="0", day_of_week="*"), ignore_result=True)
def my_test():
    pass
```

Just to confirm - I have installed celery 3.0.7 now (although django-celery
is still 3.0.6) and am still having the same issues. I am also using Redis
as a broker.

I have even dropped the DB, in case it was something caused by my south
migrations, yet the problem still persists.

Please let me know if you'd like me to try anything else.

On Tue, Aug 28, 2012 at 9:38 PM, erikcw notifications@github.com wrote:

> I'm having the same problem on 3.0.7 (django-celery 3.0.6), redis broker.
> 
> from celery.task import periodic_task
> 
> @periodic_task(run_every=crontab(hour="_", minute="0", day_of_week="_"), ignore_result=True)
> def my_test():
>     pass
> 
>  —
> Reply to this email directly or view it on GitHubhttps://github.com/celery/celery/issues/943#issuecomment-8112944.

I have upgraded to 3.0.8 and the problem still occurs. Issue should be reopened.

Note, anyone using the database scheduler have to reset the `last_run_at` fields for each periodic task:

```
$ python manage.py shell

>>> from djcelery.models import PeriodicTask
>>> PeriodicTask.objects.update(last_run_at=None)
```

I have a task scheduled for 04:00 AM and found that it's executed 2151 times (every 5 seconds) from 07:00 АМ. to 10:00 АМ and then it stops. Time here is GMT+3

Also:
python 2.7.3 
django 1.4.1 (USE_TZ = True)
virtualenv 
django-celery 3.0.6
celery 3.0.6

last_run_at is None

Has anyone with similar problem?

I have one. But in my case task runs every 5 minutes instead of run once a day. 

```
Python3.4
celery==3.1.17
Django==1.8
```

settings.py:

```
from celery.schedules import crontab

USE_TZ = True
TIME_ZONE = 'Europe/Moscow'

CELERY_ENABLE_UTC = False
CELERY_TIMEZONE = TIME_ZONE

CELERYBEAT_SCHEDULE = {
    'every-day': {
        'task': 'app.tasks.every_day',
        'schedule': crontab(minute=30, hour=0),
    },
}
```

Celery works under supervisord:

```
celery worker -A proj -l info --concurrency=2 -Ofair
celery beat -A proj  -l info
```

After 00:30 at midnight Celery sends task first time and then keep firing it until 03:30.

I'm reopening this issue due to @monax's report.
Can you please provide steps to reproduce?

@thedrow Wait a couple of days, please. I'll try to make mini project to reproduce issue.

Wonderful! thanks.

https://github.com/monax/celeryissue

In repo there is requirements.txt with all dependencies. As a broker I use rabbitmq. 

In settings.py there is a code which schedules a task to next minute after start. 

```
from celery.schedules import crontab
from datetime import datetime

USE_TZ = True
TIME_ZONE = 'Europe/Moscow'

CELERY_ENABLE_UTC = False
CELERY_TIMEZONE = TIME_ZONE

t = datetime.today()
ONE_MINUTE_AFTER = crontab(minute=t.minute + 1, hour=t.hour)

CELERYBEAT_SCHEDULE = {
    'every-day': {
        'task': 'apptask.tasks.every_day',
        'schedule': ONE_MINUTE_AFTER,
    },
}
```

Create a new virtualenv using pyvenv (python 3.4.3). Install requirements.txt and run in two terminals:

```
celery worker -A celeryissue -l info --concurrency=2 -Ofair

celery beat -A celeryissue  -l info
```

For beat you'll see:

```
celery beat -A celeryissue  -l info                  
celery beat v3.1.17 (Cipater) is starting.
__    -    ... __   -        _
Configuration ->
    . broker -> amqp://guest:**@localhost:5672//
    . loader -> celery.loaders.app.AppLoader
    . scheduler -> celery.beat.PersistentScheduler
    . db -> celerybeat-schedule
    . logfile -> [stderr]@%INFO
    . maxinterval -> now (0s)
[2015-06-15 12:35:50,911: INFO/MainProcess] beat: Starting...
[2015-06-15 12:36:00,000: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-15 12:41:00,103: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-15 12:46:00,193: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)

```

For worker you'll see something like that:

```
[2015-06-15 12:36:00,009: INFO/MainProcess] Received task: apptask.tasks.every_day[c23dd76b-1181-4115-9379-d04e69879c49]
[2015-06-15 12:36:00,013: INFO/Worker-2] Fire: 2015-06-15 12:36:00.013325
[2015-06-15 12:36:00,015: INFO/MainProcess] Task apptask.tasks.every_day[c23dd76b-1181-4115-9379-d04e69879c49] succeeded in 0.0025641939992055995s: None
[2015-06-15 12:41:00,106: INFO/MainProcess] Received task: apptask.tasks.every_day[2d746b9e-4b83-421b-8cde-a75f6a537fc1]
[2015-06-15 12:41:00,108: INFO/Worker-1] Fire: 2015-06-15 12:41:00.108269
[2015-06-15 12:41:00,110: INFO/MainProcess] Task apptask.tasks.every_day[2d746b9e-4b83-421b-8cde-a75f6a537fc1] succeeded in 0.0021385390009527327s: None
[2015-06-15 12:46:00,196: INFO/MainProcess] Received task: apptask.tasks.every_day[8487f014-98f2-444a-91da-36621a5e7edc]
[2015-06-15 12:46:00,198: INFO/Worker-2] Fire: 2015-06-15 12:46:00.197949
[2015-06-15 12:46:00,198: INFO/MainProcess] Task apptask.tasks.every_day[8487f014-98f2-444a-91da-36621a5e7edc] succeeded in 0.0014146600005915388s: None
```

I'll run it and let you know.

I can reproduce it with `celery beat -A celeryissue  -l debug --max-interval=5`

```
$ celery beat -A celeryissue  -l debug --max-interval=5
celery beat v3.1.17 (Cipater) is starting.
__    -    ... __   -        _
Configuration ->
    . broker -> amqp://guest:**@localhost:5672//
    . loader -> celery.loaders.app.AppLoader
    . scheduler -> celery.beat.PersistentScheduler
    . db -> celerybeat-schedule
    . logfile -> [stderr]@%DEBUG
    . maxinterval -> 5.00 seconds (5.0s)
[2015-06-16 20:48:56,236: DEBUG/MainProcess] Setting default socket timeout to 30
[2015-06-16 20:48:56,236: INFO/MainProcess] beat: Starting...
[2015-06-16 20:48:56,249: DEBUG/MainProcess] Current schedule:
<Entry: celery.backend_cleanup celery.backend_cleanup() <crontab: 0 4 * * * (m/h/d/dM/MY)>
<Entry: every-day apptask.tasks.every_day() <crontab: 49 20 * * * (m/h/d/dM/MY)>
[2015-06-16 20:48:56,249: DEBUG/MainProcess] beat: Ticking with max interval->5.00 seconds
[2015-06-16 20:48:56,257: DEBUG/MainProcess] Start from server, version: 0.9, properties: {'capabilities': {'basic.nack': True, 'connection.blocked': True, 'publisher_confirms': True, 'per_consumer_qos': True, 'authentication_failure_close': True, 'consumer_priorities': True, 'consumer_cancel_notify': True, 'exchange_exchange_bindings': True}, 'version': '3.5.3', 'copyright': 'Copyright (C) 2007-2014 GoPivotal, Inc.', 'information': 'Licensed under the MPL.  See http://www.rabbitmq.com/', 'cluster_name': 'rabbit@37cfe74621ef', 'platform': 'Erlang/OTP', 'product': 'RabbitMQ'}, mechanisms: ['AMQPLAIN', 'PLAIN'], locales: ['en_US']
[2015-06-16 20:48:56,258: DEBUG/MainProcess] Open OK!
[2015-06-16 20:48:56,269: DEBUG/MainProcess] beat: Waking up in 3.72 seconds.
[2015-06-16 20:49:00,000: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:49:00,001: DEBUG/MainProcess] using channel_id: 1
[2015-06-16 20:49:00,002: DEBUG/MainProcess] Channel open
[2015-06-16 20:49:00,004: DEBUG/MainProcess] beat: Synchronizing schedule...
[2015-06-16 20:49:00,012: DEBUG/MainProcess] apptask.tasks.every_day sent. id->640586be-bca2-49b4-ab5e-5f70d1477fe7
[2015-06-16 20:49:00,012: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:49:05,008: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:49:05,008: DEBUG/MainProcess] apptask.tasks.every_day sent. id->a415c0f0-a254-49b3-9272-754d7a3f283e
[2015-06-16 20:49:05,008: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:49:10,004: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:49:10,005: DEBUG/MainProcess] apptask.tasks.every_day sent. id->3906d59d-2726-49b3-8f2e-fdf339945337
[2015-06-16 20:49:10,005: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:49:15,001: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:49:15,001: DEBUG/MainProcess] apptask.tasks.every_day sent. id->8b525ba8-c569-4650-a209-859568ef62b7
[2015-06-16 20:49:15,001: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:49:19,997: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:49:19,998: DEBUG/MainProcess] apptask.tasks.every_day sent. id->02d2547b-71c8-4efc-9bb3-8daa89d6f65b
[2015-06-16 20:49:19,998: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:49:24,993: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:49:24,994: DEBUG/MainProcess] apptask.tasks.every_day sent. id->c29ef47e-d72e-4b95-a88d-fe9766229005
[2015-06-16 20:49:24,994: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:49:29,990: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:49:29,990: DEBUG/MainProcess] apptask.tasks.every_day sent. id->ba9f425c-623a-45de-9801-893e4b33f5ac
[2015-06-16 20:49:29,991: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:49:34,986: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:49:34,987: DEBUG/MainProcess] apptask.tasks.every_day sent. id->ee62e647-12c3-40dd-9360-d6607f7497b2
[2015-06-16 20:49:34,987: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:49:39,983: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:49:39,984: DEBUG/MainProcess] apptask.tasks.every_day sent. id->45d9c85e-0463-45bb-9809-7475cf107186
[2015-06-16 20:49:39,984: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:49:44,979: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:49:44,980: DEBUG/MainProcess] apptask.tasks.every_day sent. id->8229bf8b-67d6-4dc2-89a0-ffef5e7f3699
[2015-06-16 20:49:44,980: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:49:49,976: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:49:49,977: DEBUG/MainProcess] apptask.tasks.every_day sent. id->a9c797f7-1c1b-4677-8fa6-135c6f036235
[2015-06-16 20:49:49,977: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:49:54,972: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:49:54,973: DEBUG/MainProcess] apptask.tasks.every_day sent. id->2215efa0-7a45-40cc-af68-00b0cac55f4a
[2015-06-16 20:49:54,973: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:49:59,969: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:49:59,970: DEBUG/MainProcess] apptask.tasks.every_day sent. id->0bdeca69-b145-401c-9ef0-c7731c52ce6d
[2015-06-16 20:49:59,970: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:50:04,965: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:50:04,966: DEBUG/MainProcess] apptask.tasks.every_day sent. id->bad1b088-367a-4875-8594-272d3d2e6231
[2015-06-16 20:50:04,966: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:50:09,958: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:50:09,959: DEBUG/MainProcess] apptask.tasks.every_day sent. id->57d744d0-e5f1-4f29-9c7c-47e6af70a21d
[2015-06-16 20:50:09,959: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:50:14,954: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:50:14,955: DEBUG/MainProcess] apptask.tasks.every_day sent. id->6f510b48-6127-479b-ac08-3e435e0691bb
[2015-06-16 20:50:14,955: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:50:19,950: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:50:19,951: DEBUG/MainProcess] apptask.tasks.every_day sent. id->061bee73-3504-453e-90ee-7588b14f4147
[2015-06-16 20:50:19,951: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:50:24,946: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:50:24,947: DEBUG/MainProcess] apptask.tasks.every_day sent. id->eb744c6a-793b-4f9d-9d31-59c6559d3a5a
[2015-06-16 20:50:24,947: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:50:29,942: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:50:29,942: DEBUG/MainProcess] apptask.tasks.every_day sent. id->9cf3ab91-1318-42e5-b577-059437487a4d
[2015-06-16 20:50:29,943: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:50:34,938: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:50:34,939: DEBUG/MainProcess] apptask.tasks.every_day sent. id->f92e235b-1796-4b4b-8d3a-d9e386dbbbe3
[2015-06-16 20:50:34,939: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:50:39,935: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:50:39,935: DEBUG/MainProcess] apptask.tasks.every_day sent. id->63f4cfb7-03d4-4e59-add7-adc7e2c9654a
[2015-06-16 20:50:39,935: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:50:44,931: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:50:44,932: DEBUG/MainProcess] apptask.tasks.every_day sent. id->a9c2f85f-a383-4e6d-883a-bddba0e615c8
[2015-06-16 20:50:44,932: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:50:49,927: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:50:49,928: DEBUG/MainProcess] apptask.tasks.every_day sent. id->aa95f5b9-ff84-448f-93ac-eea659b12711
[2015-06-16 20:50:49,928: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:50:54,924: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:50:54,925: DEBUG/MainProcess] apptask.tasks.every_day sent. id->0ccd4878-4490-4254-ae8c-a29b7e2ddbd3
[2015-06-16 20:50:54,925: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:50:59,920: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:50:59,921: DEBUG/MainProcess] apptask.tasks.every_day sent. id->d5d8b0fd-11be-41a0-88e0-8ff04dad96f3
[2015-06-16 20:50:59,921: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:51:04,917: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:51:04,918: DEBUG/MainProcess] apptask.tasks.every_day sent. id->90129b78-cb02-4056-a523-1eff080962c3
[2015-06-16 20:51:04,918: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:51:09,909: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:51:09,910: DEBUG/MainProcess] apptask.tasks.every_day sent. id->57c50ee1-a8d1-413c-90eb-b81e1d1eba29
[2015-06-16 20:51:09,910: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:51:14,904: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:51:14,905: DEBUG/MainProcess] apptask.tasks.every_day sent. id->ec28d1f9-dd75-409e-ae0d-4eb65912586e
[2015-06-16 20:51:14,905: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:51:19,896: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:51:19,897: DEBUG/MainProcess] apptask.tasks.every_day sent. id->adcc46af-3d32-4a7a-ae57-66ff1957db85
[2015-06-16 20:51:19,897: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:51:24,893: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:51:24,893: DEBUG/MainProcess] apptask.tasks.every_day sent. id->39fbe804-115e-4719-a50c-f35ead13fb54
[2015-06-16 20:51:24,894: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:51:29,889: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:51:29,889: DEBUG/MainProcess] apptask.tasks.every_day sent. id->a918ed3d-d6b2-4b1c-aaff-f226d5f2c5c7
[2015-06-16 20:51:29,890: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:51:34,881: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:51:34,882: DEBUG/MainProcess] apptask.tasks.every_day sent. id->9062eb9c-ef0c-48f0-abe5-48841ad7631d
[2015-06-16 20:51:34,882: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:51:39,877: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:51:39,878: DEBUG/MainProcess] apptask.tasks.every_day sent. id->00d184c9-2c9a-445e-baa9-c443b3145e3e
[2015-06-16 20:51:39,878: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:51:44,871: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:51:44,872: DEBUG/MainProcess] apptask.tasks.every_day sent. id->2f66aff9-af61-4f4d-a981-f84620da054c
[2015-06-16 20:51:44,872: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:51:49,868: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:51:49,869: DEBUG/MainProcess] apptask.tasks.every_day sent. id->2cd78f61-58f0-4803-a36a-4d6801463128
[2015-06-16 20:51:49,869: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:51:54,864: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:51:54,865: DEBUG/MainProcess] apptask.tasks.every_day sent. id->f42bac9a-fef4-4e7a-a62b-b22fb7377550
[2015-06-16 20:51:54,865: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:51:59,856: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:51:59,857: DEBUG/MainProcess] apptask.tasks.every_day sent. id->11103d2c-92d2-41af-b0fa-69766e49a0d3
[2015-06-16 20:51:59,857: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:52:04,849: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:52:04,849: DEBUG/MainProcess] beat: Synchronizing schedule...
[2015-06-16 20:52:04,861: DEBUG/MainProcess] apptask.tasks.every_day sent. id->bf70a0e7-b6c4-4a8b-beb9-9106e54cca4a
[2015-06-16 20:52:04,861: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:52:09,857: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:52:09,858: DEBUG/MainProcess] apptask.tasks.every_day sent. id->f047b489-5680-4714-b20e-f64768045ee6
[2015-06-16 20:52:09,858: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:52:14,854: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:52:14,854: DEBUG/MainProcess] apptask.tasks.every_day sent. id->be6e557f-763f-4aca-a3bc-c4c5192c26bc
[2015-06-16 20:52:14,855: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:52:19,850: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:52:19,852: DEBUG/MainProcess] apptask.tasks.every_day sent. id->78ffa59b-070f-40db-bb91-fd34748db4b8
[2015-06-16 20:52:19,852: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 20:52:24,845: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 20:52:24,846: DEBUG/MainProcess] apptask.tasks.every_day sent. id->c74c558e-860a-4d6c-a46d-4e91d950c3f9
[2015-06-16 20:52:24,846: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
```

Can you please run your beat instance with debug log level and tell me what the interval is?
@ask There's something really wrong here. Can you please take a look?

I edited this issue since I can reproduce it.

~~Something is wrong with `celery.schedules.crontab.remaining_delta()`.
It returns that the task was executed a day ago even though it wasn't.~~
Sorry not correct. See below.

There's one problem with with the time zone setting that isn't being picked up from Django's TIME_ZONE setting which may or may not be by design.
Changing Celery's time zone to my local time zone causes the bug to be reproduced later:

```
/home/omer/.virtualenvs/celeryissue3/bin/python /home/omer/.virtualenvs/celeryissue3/bin/celery beat -A celeryissue -l debug --max-interval 5
celery beat v3.1.17 (Cipater) is starting.
__    -    ... __   -        _
[2015-06-16 21:34:13,892: DEBUG/MainProcess] Setting default socket timeout to 30
Configuration ->
[2015-06-16 21:34:13,892: INFO/MainProcess] beat: Starting...
    . broker -> amqp://guest:**@localhost:5672//
    . loader -> celery.loaders.app.AppLoader
    . scheduler -> celery.beat.PersistentScheduler
    . db -> celerybeat-schedule
    . logfile -> [stderr]@%DEBUG
    . maxinterval -> 5.00 seconds (5.0s)
[2015-06-16 21:34:13,899: DEBUG/MainProcess] Current schedule:
<Entry: every-day apptask.tasks.every_day() <crontab: 35 21 * * * (m/h/d/dM/MY)>
<Entry: celery.backend_cleanup celery.backend_cleanup() <crontab: 0 4 * * * (m/h/d/dM/MY)>
[2015-06-16 21:34:13,900: DEBUG/MainProcess] beat: Ticking with max interval->5.00 seconds
[2015-06-16 21:34:13,908: DEBUG/MainProcess] Start from server, version: 0.9, properties: {'cluster_name': 'rabbit@37cfe74621ef', 'version': '3.5.3', 'capabilities': {'per_consumer_qos': True, 'basic.nack': True, 'consumer_priorities': True, 'publisher_confirms': True, 'consumer_cancel_notify': True, 'authentication_failure_close': True, 'exchange_exchange_bindings': True, 'connection.blocked': True}, 'copyright': 'Copyright (C) 2007-2014 GoPivotal, Inc.', 'product': 'RabbitMQ', 'platform': 'Erlang/OTP', 'information': 'Licensed under the MPL.  See http://www.rabbitmq.com/'}, mechanisms: ['AMQPLAIN', 'PLAIN'], locales: ['en_US']
[2015-06-16 21:34:13,909: DEBUG/MainProcess] Open OK!
[2015-06-16 21:34:13,920: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 21:34:18,912: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 21:34:23,904: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 21:34:28,896: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 21:34:33,892: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 21:34:38,884: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 21:34:43,880: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 21:34:48,875: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 21:34:53,872: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 21:34:58,864: DEBUG/MainProcess] beat: Waking up in 1.13 seconds.
[2015-06-16 21:35:00,000: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 21:35:00,003: DEBUG/MainProcess] using channel_id: 1
[2015-06-16 21:35:00,005: DEBUG/MainProcess] Channel open
[2015-06-16 21:35:00,009: DEBUG/MainProcess] beat: Synchronizing schedule...
[2015-06-16 21:35:00,017: DEBUG/MainProcess] apptask.tasks.every_day sent. id->c5a94c8f-1981-4de7-b880-115de8248cb4
[2015-06-16 21:35:00,018: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 21:35:05,014: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 21:35:05,014: DEBUG/MainProcess] apptask.tasks.every_day sent. id->bfaba44b-cc10-49b3-8ba7-57b471f4ef7a
[2015-06-16 21:35:05,015: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 21:35:10,010: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 21:35:10,011: DEBUG/MainProcess] apptask.tasks.every_day sent. id->6b07e184-f6fb-4fc5-927b-9e1d733bae8a
[2015-06-16 21:35:10,012: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
[2015-06-16 21:35:15,005: INFO/MainProcess] Scheduler: Sending due task every-day (apptask.tasks.every_day)
[2015-06-16 21:35:15,007: DEBUG/MainProcess] apptask.tasks.every_day sent. id->8865e9d3-ba83-4a4a-bbd3-ce0b7eb3389d
[2015-06-16 21:35:15,007: DEBUG/MainProcess] beat: Waking up in 4.99 seconds.
```

There's definitely a bug somewhere in `celery.schedules.crontab.remaining_delta()` or surrounding it and it is related to timezones. I just have no idea what it is exactly.
The bug does not seem to reproduce when I specify `CELERY_ENABLE_UTC=True` so there's might be a workaround for this bug.
I'll keep the process running overnight to ensure that it doesn't reproduce if CELERY_ENABLE_UTC is set to true.
@monax If you'd like to assist please set a breakpoint at that function and see how it's calculated.

@thedrow I forgot one litle detail. If I try to run task 00.10 at midnight then task will be fire every 5 minutes until 03.10 after midnight. 

I'll run it with debug log level and let you know.

Ok it's verified. The bug does not reproduce if CELERY_UTC_ENABLE is set to true.
I'm going to try with master later tonight.


Resolving patch:
diff --git a/celery/schedules.py b/celery/schedules.py
--- a/celery/schedules.py
+++ b/celery/schedules.py
@@ -134,9 +134,7 @@ def is_due(self, last_run_at):
         return schedstate(is_due=False, next=remaining_s)
 
     def maybe_make_aware(self, dt):
-        if self.utc_enabled:
-            return maybe_make_aware(dt, self.tz)
-        return dt
+        return maybe_make_aware(dt, self.tz)
 
     def __repr__(self):
         return '<freq: {0.human_seconds}>'.format(self)


Test patch:
diff --git a/celery/tests/app/test_beat.py b/celery/tests/app/test_beat.py
--- a/celery/tests/app/test_beat.py
+++ b/celery/tests/app/test_beat.py
@@ -521,7 +521,7 @@ def test_maybe_make_aware(self):
         self.assertTrue(d.tzinfo)
         x.utc_enabled = False
         d2 = x.maybe_make_aware(datetime.utcnow())
-        self.assertIsNone(d2.tzinfo)
+        self.assertTrue(d2.tzinfo)
 
     def test_to_local(self):
         x = schedule(10, app=self.app)