Skip to content

Commit e48b4ae

Browse files
Add schedule management commands (#3237)
1 parent 5f41645 commit e48b4ae

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import logging
2+
3+
from django.core.management.base import BaseCommand
4+
5+
# from django.core import management
6+
from django.utils import timezone
7+
8+
logger = logging.getLogger(__name__)
9+
10+
11+
class Command(BaseCommand):
12+
help = "Runs commands scheduled to execute daily"
13+
14+
def handle(self, *args, **options):
15+
try:
16+
logger.info(f"Starting daily scheduled tasks at {timezone.now()}")
17+
18+
# Add commands to be executed daily
19+
# management.call_command('daily_command1')
20+
# management.call_command('daily_command2')
21+
except Exception as e:
22+
logger.error(f"Error in daily tasks: {str(e)}")
23+
raise
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import logging
2+
3+
from django.core.management.base import BaseCommand
4+
5+
# from django.core import management
6+
from django.utils import timezone
7+
8+
logger = logging.getLogger(__name__)
9+
10+
11+
class Command(BaseCommand):
12+
help = "Runs commands scheduled to execute hourly"
13+
14+
def handle(self, *args, **options):
15+
try:
16+
logger.info(f"Starting hourly scheduled tasks at {timezone.now()}")
17+
18+
# We can add hourly commands here
19+
# management.call_command('hourly_command1')
20+
# management.call_command('hourly_command2')
21+
except Exception as e:
22+
logger.error(f"Error in hourly tasks: {str(e)}")
23+
raise
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import logging
2+
3+
from django.core.management.base import BaseCommand
4+
5+
# from django.core import management
6+
from django.utils import timezone
7+
8+
logger = logging.getLogger(__name__)
9+
10+
11+
class Command(BaseCommand):
12+
help = "Runs commands scheduled to execute monthly"
13+
14+
def handle(self, *args, **options):
15+
try:
16+
logger.info(f"Starting monthly scheduled tasks at {timezone.now()}")
17+
18+
# Add commands to be executed monthly
19+
# management.call_command('monthly_command1')
20+
# management.call_command('monthly_command2')
21+
except Exception as e:
22+
logger.error(f"Error in monthly tasks: {str(e)}")
23+
raise
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import logging
2+
3+
from django.core.management.base import BaseCommand
4+
5+
# from django.core import management
6+
from django.utils import timezone
7+
8+
logger = logging.getLogger(__name__)
9+
10+
11+
class Command(BaseCommand):
12+
help = "Runs commands scheduled to execute weekly"
13+
14+
def handle(self, *args, **options):
15+
try:
16+
logger.info(f"Starting weekly scheduled tasks at {timezone.now()}")
17+
18+
# Add commands to be executed weekly
19+
# management.call_command('weekly_command1')
20+
# management.call_command('weekly_command2')
21+
except Exception as e:
22+
logger.error(f"Error in weekly tasks: {str(e)}")
23+
raise

0 commit comments

Comments
 (0)