4

I can run the celery beat normally using the command in the terminal, but when I go to run in aws, I get the following error:

[2019-07-10 11:30:35,166: ERROR/MainProcess] Removing corrupted schedule file 'celerybeat-schedule': error('Bad magic number',)
    Traceback (most recent call last):
      File "/opt/python/run/venv/local/lib/python3.6/site-packages/kombu/utils/objects.py", line 42, in __get__
        return obj.__dict__[self.__name__]
    KeyError: 'scheduler'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/opt/python/run/venv/local/lib/python3.6/site-packages/celery/beat.py", line 476, in setup_schedule
        self._store = self._open_schedule()
      File "/opt/python/run/venv/local/lib/python3.6/site-packages/celery/beat.py", line 466, in _open_schedule
        return self.persistence.open(self.schedule_filename, writeback=True)
      File "/usr/lib64/python3.6/shelve.py", line 243, in open
        return DbfilenameShelf(filename, flag, protocol, writeback)
      File "/usr/lib64/python3.6/shelve.py", line 227, in __init__
        Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
      File "/usr/lib64/python3.6/dbm/__init__.py", line 94, in open
        return mod.open(file, flag, mode)
    _gdbm.error: Bad magic number

Could someone please help me to understand whats's wrong?

user3358519
  • 125
  • 1
  • 8

4 Answers4

11

taken from the site.

Beat needs to store the last run times of the tasks in a local database file (named celerybeat-schedule by default), so it needs access to write in the current directory, or alternatively you can specify a custom location for this file:

celery -A proj beat -s /home/celery/var/run/celerybeat-schedule

tomerpacific
  • 4,704
  • 13
  • 34
  • 52
Lucas R.
  • 126
  • 1
  • 4
0

In my case, I was getting this error because I was trying to stop the beat process by pressing ctrl+z, because of this it was unable to save the last run times of the tasks in the local database(celerybeat-schedule file) which caused the error when I tried to run it the next time.

Try to stop it by pressing ctrl+c. I hope it works.

-1
  1. stop celery service
  2. delete beat file, something like this celerybeat-schedule.db
  3. then start the service again
-1

The most straightforward fix is as simple as:

  • Stop the Celery beat process.
  • Delete the celerybeat-schedule file.
  • Start the Celery beat process.

I run Celery beat on AWS for years and haven't had any issues with it so far.

DejanLekic
  • 18,787
  • 4
  • 46
  • 77