Open vedmant opened 3 years ago
Here's how I did it
import hashlib import json import os import sys
import django from django_crontab.crontab import Crontab
BASE_DIC = os.path.dirname(os.path.dirname(os.path.abspath(file))) if BASE_DIC not in sys.path: sys.path.insert(0, BASE_DIC)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myblog.settings")
django.setup()
jobs = django.conf.settings.CRONJOBS for job in jobs: h = hashlib.md5(json.JSONEncoder(sort_keys=True).encode( job).encode(encoding='UTF-8')).hexdigest() Crontab().run_job(h)
question; if the script in app.cron.weekly_stats.job
got changed, do I need to add
again?
Environment & Versions
Settings
django-crontab
settings:Details
The problem here is that I develop in docker and when developing a cron job I need to test it before even adding to cron. But looks like I can't run command without running
add
command?Is there a way to run it without hash, maybe passing a path like
app.cron.my_job.job
? Editing crontab file in the development environment doesn't make sense (expecially with docker as it will require rebuilding whole container), also I don't need to actually run scripts on schedule in development environment, only to test them manually.