title: Celery Daily Scheduled Tasks with Crontab
body: <p>I have problem with daily scheduled tasks with crontab.
  Here is my celery.py</p>
  
  <pre><code>app.conf.beat_schedule = {
      'run-cache-updater': {
          'task': 'tasks.run_cache_updater',
          'schedule': crontab(
              minute=0,
              hour='1-4'
          ),
      }
  }
  </code></pre>
  
  <p>Below is my tasks.py
  What I am doing there is, getting all records from DB. Triggering other jobs to update my caches on Redis.</p>
  
  <pre><code>@app.task
  def run_cache_updater():
      batch_size = 1000
      cache_records = models.CacheRecords.objects.all()
  
      def _chunk_list(all_records, size_of_batch):
          for i in range(0, len(all_records), size_of_batch):
              yield [item.id for item in all_records[i: i + batch_size]]
  
      for items in _chunk_list(cache_records, batch_size):
          update_cache.delay(items)
  
  
  @app.task
  def update_cache(ids_in_chunks):
      for id in ids_in_chunks:
          # Some calls are done here. Then sleep for 200 ms.
          time.sleep(0.2)
  </code></pre>
  
  <p>My tasks are running good. However, they start to run between 1 and 4 and then they start again every 4 hours like 8-11, 15-18..
  What I am doing wrong here and how can I fix it?</p>