Python Noob. Would like to explore some details on python scheduling. As noticed the schedule has difference in seconds(each time it run).
How to make sure the schedule job runs at 5min interval with 00 seconds. i.e., <00:05:00>
My sample code is following:
while True:
if datetime.now().minute % 5 == 0:
#do something
print(f'Date : {datetime.now()}')
time.sleep(60)
Current result:
Date : 2022-06-06 13:00:09.513017
Date : 2022-06-06 13:05:09.536887
Date : 2022-06-06 13:10:09.590000
Date : 2022-06-06 13:15:09.616859
Date : 2022-06-06 13:20:09.663668
Date : 2022-06-06 13:25:09.701900
Date : 2022-06-06 13:30:09.732448
Date : 2022-06-06 13:35:09.766074
Date : 2022-06-06 13:40:09.797849
Date : 2022-06-06 13:45:09.830098
Date : 2022-06-06 13:50:09.859578
Date : 2022-06-06 13:55:09.889196
Date : 2022-06-06 14:00:09.922575
Date : 2022-06-06 14:05:09.968444
Date : 2022-06-06 14:10:10.007531
Date : 2022-06-06 14:15:10.035127
Date : 2022-06-06 14:20:10.082590
Date : 2022-06-06 14:25:10.117690
Date : 2022-06-06 14:30:10.170962
Can notice the difference in seconds it keep incrementing. Is there a better way to do ? so the code execute at 05-min with 00 seconds?