Last active
June 11, 2021 20:27
-
-
Save anniethiessen/82ddd83caf4cb087812c8db2d1e1650c to your computer and use it in GitHub Desktop.
Django cronjobs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| * * * * * root source /opt/python/run/venv/bin/activate && cd /opt/python/current/app/ && python3 manage.py command_name >> /var/log/cronjobs.log | |
| (0 6 * * *) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 00_perform_command_cron: | |
| command: "echo .ebextensions/run_command_cron.txt > /etc/cron.d/cronjobs && chmod 644 /etc/cron.d/cronjobs" | |
| leader_only: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import timedelta | |
| from django.utils import timezone | |
| from django.core.management.base import BaseCommand | |
| class Command(BaseCommand): | |
| help = '' // TODO | |
| def handle(self, *args, **options): | |
| try: | |
| // TODO | |
| self.stdout.write(self.style.SUCCESS(f"")) | |
| except Exception as e: | |
| self.stderr.write(self.style.ERROR(f"{e}")) | |
| continue | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import timedelta | |
| from django.utils import timezone | |
| from django_cron import CronJobBase, Schedule | |
| class UpdateIngestedPaymentAmountsCronJob(CronJobBase): | |
| RUN_EVERY_MINS = 1 | |
| schedule = Schedule(run_every_mins=RUN_EVERY_MINS) | |
| code = '' // TODO | |
| def do(self): | |
| try: | |
| pass // TODO | |
| except Exception as e: | |
| // TODO | |
| continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment