How can I set up Django Crontab in Docker container?

Viewed 1632

Let's assume that I would like to run custom management command in Django every day at 12 noon. Server is deployed on Heroku in Docker container. I have in management/commands file myfile.py and I set it up in this way

TIME_ZONE = 'UTC'
CRONJOBS = [
    ('* 12 * * *', 'django.core.management.call_command', ['myfile']),
]

I added django-crontab to the requirements.txt and 'django_crontab' in INSTALLED_APPS. This file should add data to the PostgreSQL database however it doesn't work. Any ideas how can I do that? It seems to me that there is a problem with Docker. Maybe I should use Celery scheduler instead?

UPDATE I solved my problem using Heroku APScheduler. But If anyone knows how this can be resolved for instance with celery or crontab I would be grateful for the answer.

0 Answers
Related