Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django-crontab is missing job hash after one day #76

LukBR opened this issue May 9, 2018 · 3 comments


None yet
3 participants
Copy link

commented May 9, 2018

I'm using django-crontab to run a function every day in my server. Everything seems to be ok when I add crons with python crontab add (I have a local because I can see them running with crontab -l. Besides, I've tested both crons running them every minute and they executed properly.

So, the problem is when I run python crontab show on next day and it throws:

Currently active jobs in crontab:
Traceback (most recent call last):
  File "", line 22, in <module>
  File "/home/gestordocsgic/ENV/lib/python3.5/site-packages/django/core/management/", line 367, in execute_from_command_line
  File "/home/gestordocsgic/ENV/lib/python3.5/site-packages/django/core/management/", line 359, in execute
  File "/home/gestordocsgic/ENV/lib/python3.5/site-packages/django/core/management/", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/gestordocsgic/ENV/lib/python3.5/site-packages/django/core/management/", line 345, in execute
    output = self.handle(*args, **options)
  File "/home/gestordocsgic/ENV/lib/python3.5/site-packages/django_crontab/management/commands/", line 24, in handle
  File "/home/gestordocsgic/ENV/lib/python3.5/site-packages/django_crontab/", line 104, in show_jobs
    self.__get_job_by_hash(job[0][2][job[0][2].find('crontab run') + 12:].split()[0])
  File "/home/gestordocsgic/ENV/lib/python3.5/site-packages/django_crontab/", line 173, in __get_job_by_hash
    'Run "python crontab add" again to resolve this issue!' % job_hash
RuntimeError: No job with hash 9223feb793825441cf3b87a2fa36072a found. It seems
the crontab is out of sync with your settings.CRONJOBS. Run "python crontab add" 
again to resolve this issue!

It seems like it loses the hash somehow from one day to another.

I have set CRONTAB_DJANGO_PROJECT_NAME and CRONTAB_DJANGO_MANAGE_PATH, but the problem is still there. This is my

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

('0 7 * * 1-5', 'api.cron.email_to_late_docs', '>> {}'.format(BASE_DIR + '/logs/log_{:%d_%m_%Y}.log'.format(,
('0 7 * * 1-5', 'api.cron.email_ten_days_before', '>> {}'.format(BASE_DIR + 'logs/log_{:%d_%m_%Y}.log'.format(


Output of python crontab add:

  adding cronjob: (9223feb793825441cf3b87a2fa36072a) -> ('0 7 * * 1-5', 'api.cron.email_to_late_docs', '>> /home/gestordocsgic/public_html/logs/uca_09_05_2018.log')
  adding cronjob: (6c1dd239e0a8d3be61a2eb2440736fc6) -> ('0 7 * * 1-5', 'api.cron.email_ten_days_before', '>> /home/gestordocsgic/public_html/logs/uca_09_05_2018.log')

Output of crontab -l after adding cron:

0 7 * * 1-5 /home/gestordocsgic/ENV/bin/python /home/gestordocsgic/public_html/ crontab run 9223feb793825441cf3b87a2fa36072a >> /home/gestordocsgic/public_html/logs/uca_09_05_2018.log # django-cronjobs for public_html
0 7 * * 1-5 /home/gestordocsgic/ENV/bin/python /home/gestordocsgic/public_html/ crontab run 6c1dd239e0a8d3be61a2eb2440736fc6 >> /home/gestordocsgic/public_html/logs/uca_09_05_2018.log # django-cronjobs for public_html

I would appreciate any help!


This comment has been minimized.

Copy link

commented May 9, 2018

Hi, the values within CRONJOBS are changing every day as you substitute the current day. This results in different job hashes. I recommend a stable name for your logs files.


This comment has been minimized.

Copy link

commented May 14, 2018

Hi! I've changed my log files as you suggested and it worked!

Thank you :)

@kraiz kraiz closed this May 14, 2018


This comment has been minimized.

Copy link

commented Dec 13, 2018

-.- bug way can't Change to a variable file name? @kraiz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.