Closed AGDholo closed 1 year ago
schedule.every(4).hours.at("00:00").do(short)
When writing every.hour
, the .at("00:00")
relates to minutes:seconds
. In this case we are telling schedule to run the job at the 0 minutes and 0 seconds of every 4th hour.
If we are running this code at 09:30, the first execution will be at 13:00. This is because 09:00 is the 0th hour (current hour), 10:00 is the 1st hour and so is 13:00 is the 4th hour.
Now, if you need to run at exactly 00:00 - 04:00 - 08:00 - 12:00 ...
you could do something like this:
def run_job_if_hour_multiple_of_4():
current_hour = datetime.now().hour
if current_hour % 4 == 0:
job()
schedule.every(1).hour.at("00:00").do(run_job_if_hour_multiple_of_4)
https://schedule.readthedocs.io/en/stable/examples.html
If I want set a schedule at the
00:00
-04:00
-08:00
-12:00
...so, is this true?