title: Django Celery Beat Schduler sends next task with current one
body: <p>I have trouble configuring Celery Beat to reliably send tasks at the scheduled time. It sometimes sends the next scheduled task at the same time than the current one, which then messes the whole schedule.</p>
  
  <p>Here are the 4 tasks I need to run, configured in celery.py:</p>
  
  <pre><code>from __future__ import absolute_import, unicode_literals
  import os
  from celery import Celery
  from celery.schedules import crontab
  
  # set the default Django settings module for the 'celery' program.
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'oust.settings.local')
  
  app = Celery('oust')
  
  app.config_from_object('django.conf:settings', namespace='CELERY')
  
  app.autodiscover_tasks()
  
  app.conf.timezone='Europe/Zurich'
  
  
  app.conf.beat_schedule = {
      'Send pickup reminders': {
          'task': 'send_pickup_reminders',
          'schedule': crontab(hour=17, minute=0),
      },
      'Decrease pickup counters': {
          'task': 'decrease_pickup_counters',
          'schedule': crontab(hour=23, minute=55),
      },
      'Update all pickups': {
          'task': 'update_all_pickups',
          'schedule': crontab(hour=2, minute=0),
      },
      'Generate new invoices': {
          'task': 'generate_new_invoices',
          'schedule': crontab(hour=0, minute=15),
      },
  }
  </code></pre>
  
  <p>And here is an example of a task sent with the previous one :</p>
  
  <pre><code>Apr 07 19:00:00 oust-prod app/beat.1:  [2018-04-08 04:00:00,010: INFO/MainProcess] Scheduler: Sending due task celery.backend_cleanup (celery.backend_cleanup) 
  Apr 07 19:00:00 oust-prod app/worker.1:  [2018-04-08 04:00:00,017: INFO/MainProcess] Received task: celery.backend_cleanup[d3d30f13-0244-4582-8944-80fc56ae7b94]   
  Apr 07 19:00:00 oust-prod app/worker.1:  [2018-04-08 04:00:00,022: DEBUG/MainProcess] Task accepted: celery.backend_cleanup[d3d30f13-0244-4582-8944-80fc56ae7b94] pid:9 
  Apr 07 19:00:00 oust-prod app/worker.1:  [2018-04-08 04:00:00,029: INFO/MainProcess] Received task: send_pickup_reminders[e01ea890-86b2-4192-9238-0ee358e2ca1b]   
  Apr 07 19:00:00 oust-prod app/worker.1:  [2018-04-08 04:00:00,080: INFO/ForkPoolWorker-1] Task celery.backend_cleanup[d3d30f13-0244-4582-8944-80fc56ae7b94] succeeded in 0.05823612492531538s: None 
  Apr 07 19:00:00 oust-prod app/beat.1:  [2018-04-08 04:00:00,013: DEBUG/MainProcess] celery.backend_cleanup sent. id-&gt;d3d30f13-0244-4582-8944-80fc56ae7b94 
  Apr 07 19:00:00 oust-prod app/beat.1:  [2018-04-08 04:00:00,021: INFO/MainProcess] Scheduler: Sending due task send_pickup_reminders (send_pickup_reminders) 
  Apr 07 19:00:00 oust-prod app/beat.1:  [2018-04-08 04:00:00,031: DEBUG/MainProcess] send_pickup_reminders sent. id-&gt;e01ea890-86b2-4192-9238-0ee358e2ca1b 
  Apr 07 19:00:00 oust-prod app/beat.1:  [2018-04-08 04:00:00,034: DEBUG/MainProcess] beat: Waking up in 5.00 seconds. 
  Apr 07 19:00:00 oust-prod app/worker.1:  [2018-04-08 04:00:00,086: DEBUG/MainProcess] Task accepted: send_pickup_reminders[e01ea890-86b2-4192-9238-0ee358e2ca1b] pid:9 
  Apr 07 19:00:00 oust-prod app/worker.1:  [2018-04-08 04:00:00,142: INFO/ForkPoolWorker-1] Task send_pickup_reminders[e01ea890-86b2-4192-9238-0ee358e2ca1b] succeeded in 0.059483697172254324s: None 
  Apr 07 19:00:05 oust-prod app/beat.1:  [2018-04-08 04:00:05,043: DEBUG/MainProcess] beat: Waking up in 5.00 seconds.
  </code></pre>
  
  <p>Here the scheduler sends celery backend cleanup as normal at 04:00, but then also sends the next scheduled taks, send pickup reminder, which should be executed at 17:00.</p>
  
  <p>This has happened with multiple different tasks and schedules. I just can't find what causes this problem.</p>
  
  <p>Here are the relevant settings I used:</p>
  
  <p>settings.py</p>
  
  <pre><code>INSTALLED_APPS = [
      ...
      'django_celery_beat',
      'django_celery_results',
      ...
  ]
  
  TIME_ZONE = 'Europe/Zurich'
  USE_I18N = True
  USE_L10N = True
  USE_TZ = True
  </code></pre>
  
  <p>Production settings</p>
  
  <pre><code>CELERY_BROKER_URL= os.environ['REDISCLOUD_URL']
  CELERY_RESULT_BACKEND = 'django-db'
  CELERY_ACCEPT_CONTENT = ['application/json']
  CELERY_TASK_SERIALIZER = 'json'
  CELERY_RESULT_SERIALIZER = 'json'
  </code></pre>
  
  <p>Version info</p>
  
  <pre><code>Django (2.0)
  django-celery-beat (1.1.1)
  celery (4.1.0)
  </code></pre>