-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from 23wh1a0513/patch-6
Create Schedule _Run_Task
- Loading branch information
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Task Scheduler Implementation (task_scheduler.py) | ||
|
||
# List of tasks with their maximum permitted runtimes (in hours) and corresponding commands | ||
task_list = [ | ||
{"task_name": "Task1", "max_hours": 3, "cmd": r"python task1_script.py"}, | ||
{"task_name": "Task2", "max_hours": 6, "cmd": r"python task2_script.py"}, | ||
# You can add additional tasks to this list as required | ||
] | ||
|
||
# Schedule the tasks | ||
for item in task_list: | ||
schedule.every().minute.do(run_task, item["task_name"], item["max_hours"], item["cmd"]) | ||
|
||
# Infinite loop to keep the scheduler running | ||
while True: | ||
schedule.run_pending() # Execute any pending tasks | ||
time.sleep(1) # Pause for a second between checks |