-1

How can I run some code, say every 5 minutes, at exact minutes (seconds=0). I know I can get the time with datetime.datetime.now() every second and check to see if its minutes is a multiple of 5 and seconds is equal to 0 but isn't there any other way that does not require me to check the time every second?

Saeed
  • 1,848
  • 1
  • 18
  • 26

1 Answers1

0

I would use datetime like you have to get the difference in time (multiply to get seconds) from now to when you want to run the script and then use time.sleep() for that number of seconds.

https://www.pythoncentral.io/pythons-time-sleep-pause-wait-sleep-stop-your-code/

Ben Rauzi
  • 564
  • 4
  • 13