Skip to content

Instantly share code, notes, and snippets.

@anniethiessen
Last active June 11, 2021 20:27
Show Gist options
  • Select an option

  • Save anniethiessen/82ddd83caf4cb087812c8db2d1e1650c to your computer and use it in GitHub Desktop.

Select an option

Save anniethiessen/82ddd83caf4cb087812c8db2d1e1650c to your computer and use it in GitHub Desktop.
Django cronjobs
* * * * * root source /opt/python/run/venv/bin/activate && cd /opt/python/current/app/ && python3 manage.py command_name >> /var/log/cronjobs.log
(0 6 * * *)
00_perform_command_cron:
command: "echo .ebextensions/run_command_cron.txt > /etc/cron.d/cronjobs && chmod 644 /etc/cron.d/cronjobs"
leader_only: true
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
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