'Run job at specific 5 mins interval in python

I would like to run the job at :00, :05 , :10, :15, :20, ....., :55.

So, if the execution of code started at 16:31:10 the job should run at 16:35:00

Am using the below code:

import schedule
import time
from datetime import datetime, timezone, timedelta


print("Started Exec:- " + str(datetime.now()))

def job():
    print("Job:- " + str(datetime.now()))


schedule.every(5).minutes.do(job)


while True:
    schedule.run_pending()
    time.sleep(1)

But the job ran at 16:36:10

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source