0

I'm using django-crontabto 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?

Alberto
  • 1,348
  • 2
  • 14
  • 28

3 Answers3

3

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.

Alberto
  • 1,348
  • 2
  • 14
  • 28
0

In case someone has this problem in the future, the answer from Alberto worked for me. Also, don't use relative paths for the log file. For example, "~/path/to/file" gets translated to something like "/home/user/path/to/file" which changes the hash as well. Use an absolute path

0

run

python manage.py crontab run <your task>

for example python manage.py crontab run 2755b3a03042fdf7b9c8edbcaff737f6 after run python manage.py crontab remove

Yuriy
  • 1