File tree 1 file changed +9
-29
lines changed
1 file changed +9
-29
lines changed Original file line number Diff line number Diff line change 1
- import schedule
2
1
import time
3
- import logging
4
-
5
- # Set up logging
6
- logging .basicConfig (
7
- filename = 'task_scheduler.log' ,
8
- level = logging .INFO ,
9
- format = '%(asctime)s - %(message)s' ,
10
- datefmt = '%Y-%m-%d %H:%M:%S'
11
- )
2
+ import schedule
12
3
13
- # Example task 1: Function to be scheduled
14
- def task_one ():
15
- logging .info ("Task 1 is running" )
4
+ def task ():
5
+ print ("Task is being executed" )
16
6
17
- # Example task 2: Another task to be scheduled
18
- def task_two ():
19
- logging .info ("Task 2 is running" )
7
+ def task2 ():
8
+ print ("Another task is being executed" )
20
9
21
- # Schedule tasks
22
- def setup_schedule ():
23
- # Schedule task_one every 10 minutes
24
- schedule .every (10 ).minutes .do (task_one )
25
-
26
- # Schedule task_two every hour
27
- schedule .every ().hour .do (task_two )
28
-
29
- # Add more tasks here as needed
10
+ def run_tasks ():
11
+ schedule .every (1 ).minutes .do (task )
12
+ schedule .every (2 ).minutes .do (task2 )
30
13
31
- # Main loop to keep the scheduler running
32
- def run_scheduler ():
33
- setup_schedule ()
34
14
while True :
35
15
schedule .run_pending ()
36
16
time .sleep (1 )
37
17
38
18
if __name__ == "__main__" :
39
- run_scheduler ()
19
+ run_tasks ()
You can’t perform that action at this time.
0 commit comments