Closed Noam5 closed 1 year ago
In the example you provided, the job is scheduled to run every day at 10:00. If the computer is hibernating until 11:00, the scheduled task will be run whenever the computer wakes up and the run_pending() function is called.
Every job has an next_run
variable with a datetime that indicates when the next job should run. This can be seen when you print the job:
print(repr(schedule.every().day.at("10:00").do(job,'It is 01:00')))
# Every 1 day at 10:00:00 do job('It is 01:00') (last run: [never], next run: 2023-04-11 10:00:00)
The run_pending
simply looks at all the jobs' next_run
, and whenever the current time is equal or after the next_run
, it will run the job and calculate the new next_run
. So when the program execution was paused (run_pending was not called for a long time), then whenever the next time run_pending
runs, all missed jobs are ran.
Happy scheduling!
For example the code:
But the computer was hibernating until 11:00? will the task still be scheduled? what about 23 hours later?