schedule icon indicating copy to clipboard operation
schedule copied to clipboard

How to do job once at a specific date and time?

Open Futyn-Maker opened this issue 2 years ago • 1 comments

Hello!

I need a Python script that executes some task once in a specific date and time? Can I do it using Schedule? In the documentation I've found such a code:

schedule.every().day.at('22:30').do(job_that_executes_once)

It works, but I need something like this:

schedule.every().day.at('2022-04-03 22:30').do(job_that_executes_once)

But this code returns an error. Can I do it in some way?

Thanks!

Futyn-Maker avatar Mar 30 '22 23:03 Futyn-Maker

https://schedule.readthedocs.io/en/stable/examples.html#run-a-job-once so i would do the following:

  • Run the job every day at 22:30
  • inside the called function check if the date is the correct one
  • if it is the correct one, run the code and finally cancel the job
  • if the date isn't the correct one, break out from the job

faulander avatar Apr 04 '22 10:04 faulander