schedule¶
Python job scheduling for humans. Run Python functions (or any other callable) periodically using a friendly syntax.
- A simple to use API for scheduling jobs, made for humans.
- In-process scheduler for periodic jobs. No extra processes needed!
- Very lightweight and no external dependencies.
- Excellent test coverage.
- Tested on Python 3.7, 3.8, 3.9, 3.10 and 3.11
Example¶
$ pip install schedule
import schedule
import time
def job():
print("I'm working...")
schedule.every(10).minutes.do(job)
schedule.every().hour.do(job)
schedule.every().day.at("10:30").do(job)
schedule.every().monday.do(job)
schedule.every().wednesday.at("13:15").do(job)
schedule.every().day.at("12:42", "Europe/Amsterdam").do(job)
schedule.every().minute.at(":17").do(job)
while True:
schedule.run_pending()
time.sleep(1)
More Examples
When not to use Schedule¶
Let’s be honest, Schedule is not a ‘one size fits all’ scheduling library. This library is designed to be a simple solution for simple scheduling problems. You should probably look somewhere else if you need:
- Job persistence (remember schedule between restarts)
- Exact timing (sub-second precision execution)
- Concurrent execution (multiple threads)
- Localization (workdays or holidays)
Schedule does not account for the time it takes for the job function to execute. To guarantee a stable execution schedule you need to move long-running jobs off the main-thread (where the scheduler runs). See Parallel execution for a sample implementation.
Read More¶
- Installation
- Examples
- Run a job every x minute
- Use a decorator to schedule a job
- Pass arguments to a job
- Cancel a job
- Run a job once
- Get all jobs
- Cancel all jobs
- Get several jobs, filtered by tags
- Cancel several jobs, filtered by tags
- Run a job at random intervals
- Run a job until a certain time
- Time until the next execution
- Run all jobs now, regardless of their scheduling
- Run in the background
- Parallel execution
- Timezone & Daylight Saving Time
- Exception Handling
- Logging
- Multiple schedulers
- Frequently Asked Questions
- AttributeError: ‘module’ object has no attribute ‘every’
- ModuleNotFoundError: No module named ‘schedule’
- ModuleNotFoundError: ModuleNotFoundError: No module named ‘pytz’
- Does schedule support time zones?
- What if my task throws an exception?
- How can I run a job only once?
- How can I cancel several jobs at once?
- How to execute jobs in parallel?
- How to continuously run the scheduler without blocking the main thread?
- Another question?
- Reference
- Development
Issues¶
If you encounter any problems, please file an issue along with a detailed description. Please also use the search feature in the issue tracker beforehand to avoid creating duplicates. Thank you 😃
About Schedule¶
Created by Daniel Bader - @dbader_org
Inspired by Adam Wiggins’ article “Rethinking Cron” and the clockwork Ruby module.
Distributed under the MIT license. See LICENSE.txt
for more information.
Thanks to all the wonderful folks who have contributed to schedule over the years:
- mattss <https://github.com/mattss>
- mrhwick <https://github.com/mrhwick>
- cfrco <https://github.com/cfrco>
- matrixise <https://github.com/matrixise>
- abultman <https://github.com/abultman>
- mplewis <https://github.com/mplewis>
- WoLfulus <https://github.com/WoLfulus>
- dylwhich <https://github.com/dylwhich>
- fkromer <https://github.com/fkromer>
- alaingilbert <https://github.com/alaingilbert>
- Zerrossetto <https://github.com/Zerrossetto>
- yetingsky <https://github.com/yetingsky>
- schnepp <https://github.com/schnepp> <https://bitbucket.org/saschaschnepp>
- grampajoe <https://github.com/grampajoe>
- gilbsgilbs <https://github.com/gilbsgilbs>
- Nathan Wailes <https://github.com/NathanWailes>
- Connor Skees <https://github.com/ConnorSkees>
- qmorek <https://github.com/qmorek>
- aisk <https://github.com/aisk>
- MichaelCorleoneLi <https://github.com/MichaelCorleoneLi>
- sijmenhuizenga <https://github.com/SijmenHuizenga>
- eladbi <https://github.com/eladbi>
- chankeypathak <https://github.com/chankeypathak>
- vubon <https://github.com/vubon>
- gaguirregabiria <https://github.com/gaguirregabiria>
- rhagenaars <https://github.com/RHagenaars>
- Skenvy <https://github.com/skenvy>
- zcking <https://github.com/zcking>
- Martin Thoma <https://github.com/MartinThoma>
- ebllg <https://github.com/ebllg>
- fredthomsen <https://github.com/fredthomsen>
- biggerfisch <https://github.com/biggerfisch>
- sosolidkk <https://github.com/sosolidkk>
- rudSarkar <https://github.com/rudSarkar>
- chrimaho <https://github.com/chrimaho>
- jweijers <https://github.com/jweijers>
- Akuli <https://github.com/Akuli>
- NaelsonDouglas <https://github.com/NaelsonDouglas>
- SergBobrovsky <https://github.com/SergBobrovsky>
- CPickens42 <https://github.com/CPickens42>
- emollier <https://github.com/emollier>
- sunpro108 <https://github.com/sunpro108>