I'm using django-crontab
to run a function every day in my server. When I add the cron with python manage.py crontab add
everything is ok, I can see the crons and they execute normally (I've tested them running every minute and they do what I want). The problem is the next day it always throws this error:
RuntimeError: No job with hash bdd84e8eebbbbc48c5d39e0245c78c93 found. It
seems the crontab is out of sync with your settings.CRONJOBS. Run "python
manage.py crontab add" again to resolve this issue!`
I have set the CRONTAB_DJANGO_PROJECT_NAME
and CRONTAB_DJANGO_MANAGE_PATH
because i have a local manage.py
.
Seems like it loses the hash somehow from one day to another. This is my settings:
CRONJOBS = [
('0 7 * * 1-5', 'api.cron.email_to_late_docs', '>> {}'.format(BASE_DIR + '/logs/log_{:%d_%m_%Y}.log'.format(time.now()))),
('0 7 * * 1-5', 'api.cron.email_ten_days_before', '>> {}'.format(BASE_DIR + 'logs/log_{:%d_%m_%Y}.log'.format(time.now())))
]
CRONTAB_DJANGO_PROJECT_NAME = 'public_html'
CRONTAB_DJANGO_MANAGE_PATH = BASE_DIR + '/manage_local.py'
Has someone face this error before?
In case someone face this problem in the future, It turns out it was a problem with the logs name. Changing the name of the logs to a stable name solved the problem.