0

I need to run a python script at specific time at EVERY minutes. I CANNOT use time.sleep to wait 60 second for it, because my script takes 8-10 seconds to run, (60 + 8 = 68 or 60+10 = 70) I need to run the script at below specific time through out the day.

2023-01-09 01:01:05
2023-01-09 01:02:05
2023-01-09 01:03:05
2023-01-09 01:04:05
2023-01-09 01:05:05

I do lots of search and can't find a good answer. Worse case should i create a dataframe to tell the script based on the time?

besides, in window Task Scheduler,I don't see there's a option to set 1 Minute recurring.

thanks

PyBoss
  • 599
  • 1
  • 7
  • 20

1 Answers1

1

You can calculate the time when it should next run and then do:

time.sleep(nextime - datetime.now())
Christian
  • 25,249
  • 40
  • 134
  • 225