From c3facf635034e4eca058d8ffdd6d063afe81a88d Mon Sep 17 00:00:00 2001 From: 23wh1a0513 <150132045+23wh1a0513@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:42:12 +0530 Subject: [PATCH] Create Schedule _Run_Task --- Schedule _Run_Task | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Schedule _Run_Task diff --git a/Schedule _Run_Task b/Schedule _Run_Task new file mode 100644 index 0000000..6623ea2 --- /dev/null +++ b/Schedule _Run_Task @@ -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