Skip to content

Commit

Permalink
Add schedule management commands
Browse files Browse the repository at this point in the history
  • Loading branch information
SahilDhillon21 committed Jan 17, 2025
1 parent 5f41645 commit bd579b7
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
23 changes: 23 additions & 0 deletions website/management/commands/run_daily.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logging

from django.core.management.base import BaseCommand

# from django.core import management
from django.utils import timezone

logger = logging.getLogger(__name__)


class Command(BaseCommand):
help = "Runs commands scheduled to execute daily"

def handle(self, *args, **options):
try:
logger.info(f"Starting daily scheduled tasks at {timezone.now()}")

# Add commands to be executed daily
# management.call_command('daily_command1')
# management.call_command('daily_command2')
except Exception as e:
logger.error(f"Error in daily tasks: {str(e)}")
raise
23 changes: 23 additions & 0 deletions website/management/commands/run_hourly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logging

from django.core.management.base import BaseCommand

# from django.core import management
from django.utils import timezone

logger = logging.getLogger(__name__)


class Command(BaseCommand):
help = "Runs commands scheduled to execute hourly"

def handle(self, *args, **options):
try:
logger.info(f"Starting hourly scheduled tasks at {timezone.now()}")

# We can add hourly commands here
# management.call_command('hourly_command1')
# management.call_command('hourly_command2')
except Exception as e:
logger.error(f"Error in hourly tasks: {str(e)}")
raise
23 changes: 23 additions & 0 deletions website/management/commands/run_monthly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logging

from django.core.management.base import BaseCommand

# from django.core import management
from django.utils import timezone

logger = logging.getLogger(__name__)


class Command(BaseCommand):
help = "Runs commands scheduled to execute monthly"

def handle(self, *args, **options):
try:
logger.info(f"Starting monthly scheduled tasks at {timezone.now()}")

# Add commands to be executed monthly
# management.call_command('monthly_command1')
# management.call_command('monthly_command2')
except Exception as e:
logger.error(f"Error in monthly tasks: {str(e)}")
raise
23 changes: 23 additions & 0 deletions website/management/commands/run_weekly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logging

from django.core.management.base import BaseCommand

# from django.core import management
from django.utils import timezone

logger = logging.getLogger(__name__)


class Command(BaseCommand):
help = "Runs commands scheduled to execute weekly"

def handle(self, *args, **options):
try:
logger.info(f"Starting weekly scheduled tasks at {timezone.now()}")

# Add commands to be executed weekly
# management.call_command('weekly_command1')
# management.call_command('weekly_command2')
except Exception as e:
logger.error(f"Error in weekly tasks: {str(e)}")
raise

0 comments on commit bd579b7

Please sign in to comment.