-
Notifications
You must be signed in to change notification settings - Fork 961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run job once and only once #33
Comments
Hi @ydoow, you can achieve that by doing the following: def job_that_executes_once():
# Do some work ...
return schedule.CancelJob
schedule.today.at('10:30').do(job_that_executes_once) Basically you let the job cancel itself the first time it executes. |
Added this to the FAQ in #35. |
Sorry to comment on an old issue but the above code snippet does not actually seem to work. I have just tried the following and got the error that the attribute today does not exist (i also checked the code and can't see today as part of scheduler or job):
Then to double check that scheduler is working for me i did the following:
|
In my uses I've been wanting to run a job only once at a specific time, then cancel it.
This program is so intuitively worded that I keep thinking it's supported.
Something like
schedule.today.at('10:30').do(job)
I've been working around it by scheduling it every hour/day/week at the time I desire, then cancelling the job right after it executes. It's a tad tedious though because I have to manually keep a reference to the job ID to later cancel that one job, and it looks clunky of course.
The text was updated successfully, but these errors were encountered: