Question: I am getting this issue while re-build and re-start `cookiecutter-django` `docker-compose` in production. I am able to solve this by either removing all stopped docker containers or by adding `rm -f './celerybeat.pid'` in `/compose/production/django/celery/beat/start.sh` similar to `/compose/local/django/celery/beat/start.sh`. Is there any reason for not including this specific code in production version of compose file?

Answer: 
If you can live without `beat`, there's a way for celery to handle periodic tasks by passing in the 'B' flag. When you do this, no .pid file is generated, a `celerybeat-schedule` file is generated. When you rerun celery, it won't complain about reusing this file. As far as source control does, just add it to your .gitignore.

Here's the command in full form:

`celery -A <appname> worker -l info -BE`
Other way, create a django command celery\_kill.py

```
import shlex
import subprocess

from django.core.management.base import BaseCommand

class Command(BaseCommand):
    def handle(self, *args, **options):
        kill_worker_cmd = 'pkill -9 celery'
        subprocess.call(shlex.split(kill_worker_cmd))

```

docker-compose.yml :

```
celery:
    build: ./src
    restart: always
    command: celery -A project worker -l info
    volumes:
      - ./src:/var/lib/celery/data/
    depends_on:
      - db
      - redis
      - app

  celery-beat:
    build: ./src
    restart: always
    command: celery -A project beat -l info --pidfile=/tmp/celeryd.pid
    volumes:
      - ./src:/var/lib/beat/data/
    depends_on:
      - db
      - redis
      - app

```

and Makefile:

```
run:
    docker-compose up -d --force-recreate
    docker-compose exec app python manage.py celery_kill
    docker-compose restart
    docker-compose exec app python manage.py migrate

```