Python job scheduling for humans.

Overview

schedule

https://coveralls.io/repos/dbader/schedule/badge.svg?branch=master

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 and 3.6, 3.7, 3.8, 3.9

Usage

$ pip install schedule
import schedule
import time

def job():
    print("I'm working...")

schedule.every(10).seconds.do(job)
schedule.every(10).minutes.do(job)
schedule.every().hour.do(job)
schedule.every().day.at("10:30").do(job)
schedule.every(5).to(10).minutes.do(job)
schedule.every().monday.do(job)
schedule.every().wednesday.at("13:15").do(job)
schedule.every().minute.at(":17").do(job)

while True:
    schedule.run_pending()
    time.sleep(1)

Documentation

Schedule's documentation lives at schedule.readthedocs.io.

Meta

Daniel Bader - @dbader_org - [email protected]

Inspired by Adam Wiggins' article "Rethinking Cron" and the clockwork Ruby module.

Distributed under the MIT license. See LICENSE.txt for more information.

https://github.com/dbader/schedule

Comments
  • 'module' object has no attribute 'every'

    'module' object has no attribute 'every'

    schedule.every(10).minutes.do(job) AttributeError: 'module' object has no attribute 'every'

    My full code

    import schedule import time

    def job(): print("Helo Wolrd ")

    schedule.every(10).minutes.do(job) schedule.every().hour.do(job)

    while True: schedule.run_pending() time.sleep(1)

    question 
    opened by atuljain 20
  • ✨ Schedule roadmap + discussion

    ✨ Schedule roadmap + discussion

    Hey folks πŸ‘‹

    Progress on schedule has been kinda stale for a while now and I'd like to kick things into gear again.

    We've had a bunch of open issues and PRs that I'm triaging right now. Thanks to everyone who helped out answering usage and how-to questions, I really appreciate it! 😊

    I've created this issue so we can discuss next steps for another schedule release in November.

    We have a bunch of PRs cooking at the moment and some of them I think would make good additions.

    However, one thing I want to avoid is growing schedule "randomly" by adding half-baked or too niche features. I think people like schedule because its interface is simple and straight-forward.

    I'm worried schedule will lose its simplicity.

    I don't think we should build another APScheduler or a replacement for Cron.

    That's definitely something that will be tough to balance and I'd love to hear your opinions on that topic as well πŸ˜ƒ .

    I also think there are some must do's that we should tackle in the next release. For me those include:

    • [x] Fix the CI build (done in #79)
    • [x] Adding Wheel support for faster installs from PyPI
    • [x] Setting up proper docs and expanding the FAQ (see #4). This will help keep questions like "how can I cancel jobs?" under control.

    Again I'd love to hear input on that, please fire away πŸ˜ƒ

    I've also toyed with the idea of setting up a Gitter chat room for schedule. I've seen this working well on other projects and I'd be happy to set it up if there's enough interest in it.

    contributor friendly 
    opened by dbader 15
  • Timezone support

    Timezone support

    Hi,

    I added timezone support using python-dateutil. Yes, it's not as minimal as before, but I think the functionality makes up for it. :-) Hope you agree.

    Ivan

    opened by imiric 15
  •  Support for parsing of string interval definitions

    Support for parsing of string interval definitions

    As a user, I want to be able to specify an interval definition as a string. This pull request implements this functionality. It parses the input string and calls the appropriate properties and functions. It slightly abuses asserts but you did not define any custom exceptions and I wanted to follow your style.

    This is how it works:

    schedule.when('every wednesday at 13:15').do(job)
    schedule.when('every 15 seconds').do(job)
    
    opened by ljanyst 13
  • Monthly periodicity

    Monthly periodicity

    Developed monthly periodicity functionality.

    Monthly periodicity always need to have defined 'at("DD-HH:MM:SS")' or 'at("DD-HH:MM")', where "DD" is the day of the month it should run. If "DD"=31 the periodic job will run the last day on the month.

    Other exceptions related to end of month dates or February special case are controlled, at least as far as I've been able to check.

    opened by gaguirregabiria 12
  • Scheduled tasks are not called anymore

    Scheduled tasks are not called anymore

    Everything was fine, but on the last week scheduling stopped working. I made some testing: I have a script which defines few scheduled tasks. When running from command string this way: python myscript.py schedule work just fine. But when I run this script from another script: newprocess="nohup python myscript.py" os.system(newprocess) the scheduled tasks are not called there. in myscript.py, schedule is performed in a separate thread: `def scheduler_function(): while 1: schedule.run_pending() time.sleep(1)

    thread = Thread(target = scheduler_function, args = ()) thread.start()`

    Can you please help me with this?

    opened by madfatcat 12
  • Clear jobs by tag

    Clear jobs by tag

    The intention of this pull is to create an easy way to clear scheduled jobs in a modular environment. For doing this i added two new methods to Job class, tag() and tags(), that could be used in a way like this one

    schedule.every(10).minutes.do(job).tag('my_tag', 'my_other_tag')

    after doing this it will be possible to clear a subset of jobs by doing

    schedule.clear('my_other_tag')

    always leaving the older way possible by omitting the tag parameter. Please, tell me if you think it could be useful.

    opened by Zerrossetto 12
  • Add support for random intervals

    Add support for random intervals

    For tasks that should run at an irregular interval, this adds the following syntax:

    schedule.every(10).to(20).hours.do(job)
    

    The scheduler picks a random value in that range as the actual interval used when scheduling the next run.

    Review on Reviewable

    opened by grampajoe 12
  • More ruby-like syntax for `schedule.every`

    More ruby-like syntax for `schedule.every`

    Now to schedule new job uses the following syntax:

    schedule.every(10).minutes.do(job)
    

    Maybe the more consistent to use

    schedule.every.10.minutes.do(job)
    

    Any thoughts?

    opened by vitalk 12
  • TypeError: can't compare datetime.datetime to NoneType

    TypeError: can't compare datetime.datetime to NoneType

    I ran your example, and I got the following error -->

    schedule.run_pending() Traceback (most recent call last): File "", line 1, in File "//anaconda/lib/python2.7/site-packages/schedule/init.py", line 462, in run_pending default_scheduler.run_pending() File "//anaconda/lib/python2.7/site-packages/schedule/init.py", line 74, in run_pending for job in sorted(runnable_jobs): File "//anaconda/lib/python2.7/site-packages/schedule/init.py", line 73, in runnable_jobs = (job for job in self.jobs if job.should_run) File "//anaconda/lib/python2.7/site-packages/schedule/init.py", line 368, in should_run return datetime.datetime.now() >= self.next_run TypeError: can't compare datetime.datetime to NoneType

    bug 
    opened by adtrombley 11
  • Schedule every hour

    Schedule every hour

    At the moment it is possible to schedule a task to run every hour however it schedules the task every hour from the moment it is added to the cue. There is no convenient way to schedule a task every "whole" hour (You'd have to add the job 24 times on the hour..)

    Suggestion for improvement: enable "whole hour" cues.

    opened by DieterKoblenz 11
  • Wrong documentation with timezone

    Wrong documentation with timezone

    schedule.every().day.at("12:42", "Europe/Amsterdam").do(job)
    

    This piece of code just does not work. It shows that at excepts two arguments but three were given.

    opened by nilansaha 1
  • need .until() for python 2.7

    need .until() for python 2.7

    hello, i'm using a device that has a python sdk that can't be upgraded and uses python 2.7. Is there anyway that you can make 1.1.0 compatible with python2.7 or create 0.6.1 that has .until function?

    opened by NicoEichen 0
  • Bi-weekly and bi-weekly the other week

    Bi-weekly and bi-weekly the other week

    Question: Is there a way to run a job every second or third week on a specific day and time (week 1,3,5,7...) ? And similar, is there a way to slide it 1 week (week 2,4,6,8...) ? E.g. running jobA on Mondays in odd-numbered weeks, and jobB on even-numbered weeks.

    I know it can be solved with modifying the job-function itself.

    opened by tessem 0
  • Unable to fetch the  Jobs list

    Unable to fetch the Jobs list

    Hi

    I have created a schedule job that execute the application data backup daily at for a given time (like daily @ 18:00:00) in Django Application. When I start the application, it starts all the configured schedule jobs. But when I try to fetch the jobs that are scheduled I get an empty list.

    image

    image

    image

    opened by mayurproventech 0
  • What happens when a job is

    What happens when a job is "missed" at the scheduled time?

    For example the code:

    import schedule
    import time
    
    def job(t):
        print "I'm working...", t
        return
    
    schedule.every().day.at("10:00").do(job,'It is 01:00')
    
    while True:
        schedule.run_pending()
        time.sleep(60) # wait one minute
    
    

    But the computer was hibernating until 11:00? will the task still be scheduled? what about 23 hours later?

    opened by Noam5 0
  • Run with instance method

    Run with instance method

    Is it possible to run functions of instance methods that accesses self within the function using the decorator?

    When I try to run this, the function throws an error missing 1 required positional argument: 'self'

    (this seems a very basic question, but I could not find any answer to it, so sorry if it is already answered somewhere)

    opened by skjerns 0
Owner
Dan Bader
Full-stack Pythonista & Python Coach. Write Clean and Pythonic code with my free tutorials, books, and courses.
Dan Bader
A Python concurrency scheduling library, compatible with asyncio and trio.

aiometer aiometer is a Python 3.6+ concurrency scheduling library compatible with asyncio and trio and inspired by Trimeter. It makes it easier to exe

Florimond Manca 182 Dec 26, 2022
CoSA: Scheduling by Constrained Optimization for Spatial Accelerators

CoSA is a scheduler for spatial DNN accelerators that generate high-performance schedules in one shot using mixed integer programming

UC Berkeley Architecture Research 44 Dec 13, 2022
Clepsydra is a mini framework for task scheduling

Intro Clepsydra is a mini framework for task scheduling All parts are designed to be replaceable. Main ideas are: No pickle! Tasks are stored in reada

Andrey Tikhonov 15 Nov 4, 2022
A task scheduler with task scheduling, timing and task completion time tracking functions

A task scheduler with task scheduling, timing and task completion time tracking functions. Could be helpful for time management in daily life.

ArthurLCW 0 Jan 15, 2022
dragonscales is a highly customizable asynchronous job-scheduler framework

dragonscales ?? dragonscales is a highly customizable asynchronous job-scheduler framework. This framework is used to scale the execution of multiple

Sorcero 2 May 16, 2022
Crontab jobs management in Python

Plan Plan is a Python package for writing and deploying cron jobs. Plan will convert Python code to cron syntax. You can easily manage you

Shipeng Feng 1.2k Dec 28, 2022
A powerful workflow engine implemented in pure Python

Spiff Workflow Summary Spiff Workflow is a workflow engine implemented in pure Python. It is based on the excellent work of the Workflow Patterns init

Samuel 1.3k Jan 8, 2023
Python-Repeated-Timer is an open-source & highly performing timer using only standard-libraries.

Python Repeated Timer Python-Repeated-Timer is an open-source & highly performing timer using only standard-libraries.

TACKHYUN JUNG 3 Oct 9, 2022
Automate SQL Jobs Monitoring with python

Automate_SQLJobsMonitoring_python Using python 3rd party modules we can automate

Aejaz Ayaz 1 Dec 27, 2021
Python job scheduling for humans.

schedule Python job scheduling for humans. Run Python functions (or any other callable) periodically using a friendly syntax. A simple to use API for

Dan Bader 10.4k Jan 2, 2023
Python job scheduling for humans.

schedule Python job scheduling for humans. Run Python functions (or any other callable) periodically using a friendly syntax. A simple to use API for

Dan Bader 10.4k Jan 2, 2023
Driving lessons made simpler. Custom scheduling API built with Python.

NOTE This is a mirror of a GitLab repository. Dryvo Dryvo is a unique solution for the driving lessons industry. Our aim is to save the teacher’s time

Adam Goldschmidt 595 Dec 5, 2022
OptaPy is an AI constraint solver for Python to optimize planning and scheduling problems.

OptaPy is an AI constraint solver for Python to optimize the Vehicle Routing Problem, Employee Rostering, Maintenance Scheduling, Task Assignment, School Timetabling, Cloud Optimization, Conference Scheduling, Job Shop Scheduling, Bin Packing and many more planning problems.

OptaPy 208 Dec 27, 2022
A Python concurrency scheduling library, compatible with asyncio and trio.

aiometer aiometer is a Python 3.6+ concurrency scheduling library compatible with asyncio and trio and inspired by Trimeter. It makes it easier to exe

Florimond Manca 182 Dec 26, 2022
Simple alternative to Doodle polls and scheduling (Python 3, Django 3, JavaScript)

What is jawanndenn? jawanndenn is a simple web application to schedule meetings and run polls, a libre alternative to Doodle. It is using the followin

Sebastian Pipping 169 Jan 6, 2023
Conference planning tool: CfP, scheduling, speaker management

pretalx is a conference planning tool focused on providing the best experience for organisers, speakers, reviewers, and attendees alike. It handles th

null 492 Dec 28, 2022
Conference planning tool: CfP, scheduling, speaker management

pretalx is a conference planning tool focused on providing the best experience for organisers, speakers, reviewers, and attendees alike. It handles th

null 496 Dec 31, 2022
Oncall is a calendar tool designed for scheduling and managing on-call shifts. It can be used as source of dynamic ownership info for paging systems like http://iris.claims.

Oncall See admin docs for information on how to run and manage Oncall. Development setup Prerequisites Debian/Ubuntu - sudo apt-get install libsasl2-d

LinkedIn 928 Dec 22, 2022
CoSA: Scheduling by Constrained Optimization for Spatial Accelerators

CoSA is a scheduler for spatial DNN accelerators that generate high-performance schedules in one shot using mixed integer programming

UC Berkeley Architecture Research 44 Dec 13, 2022