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 job launching library for docker, EC2, GCP, etc.

doodad A library for packaging dependencies and launching scripts (with a focus on python) on different platforms using Docker. Currently supported pl

Justin Fu 55 Aug 27, 2022
Python IMDB Docker - A docker tutorial to containerize a python script.

Python_IMDB_Docker A docker tutorial to containerize a python script. Build the docker in the current directory: docker build -t python-imdb . Run the

Sarthak Babbar 1 Dec 30, 2021
Honcho: a python clone of Foreman. For managing Procfile-based applications.

___ ___ ___ ___ ___ ___ /\__\ /\ \ /\__\ /\ \ /\__\ /\

Nick Stenning 1.5k Jan 3, 2023
Cross-platform lib for process and system monitoring in Python

Home Install Documentation Download Forum Blog Funding What's new Summary psutil (process and system utilities) is a cross-platform library for retrie

Giampaolo Rodola 9k Jan 2, 2023
A Python library for the Docker Engine API

Docker SDK for Python A Python library for the Docker Engine API. It lets you do anything the docker command does, but from within Python apps – run c

Docker 6.1k Dec 31, 2022
The leading native Python SSHv2 protocol library.

Paramiko Paramiko: Python SSH module Copyright: Copyright (c) 2009 Robey Pointer <[email protected]> Copyright: Copyright (c) 2020 Jeff Forcier <

null 8.1k Jan 4, 2023
Official Python client library for kubernetes

Kubernetes Python Client Python client for the kubernetes API. Installation From source: git clone --recursive https://github.com/kubernetes-client/py

Kubernetes Clients 5.4k Jan 2, 2023
A cron monitoring tool written in Python & Django

Healthchecks Healthchecks is a cron job monitoring service. It listens for HTTP requests and email messages ("pings") from your cron jobs and schedule

Healthchecks 5.8k Jan 2, 2023
Remote Desktop Protocol in Twisted Python

RDPY Remote Desktop Protocol in twisted python. RDPY is a pure Python implementation of the Microsoft RDP (Remote Desktop Protocol) protocol (client a

Sylvain Peyrefitte 1.6k Dec 30, 2022
Python utility function to communicate with a subprocess using iterables: for when data is too big to fit in memory and has to be streamed

iterable-subprocess Python utility function to communicate with a subprocess using iterables: for when data is too big to fit in memory and has to be

Department for International Trade 5 Jul 10, 2022
Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions

Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions

Arie Bregman 35.1k Jan 2, 2023
Push Container Image To Docker Registry In Python

push-container-image-to-docker-registry 概要 push-container-image-to-docker-registry は、エッジコンピューティング環境において、特定のエッジ端末上の Private Docker Registry に特定のコンテナイメー

Latona, Inc. 3 Nov 4, 2021
Get Response Of Container Deployment Kube with python

get-response-of-container-deployment-kube 概要 get-response-of-container-deployment-kube は、例えばエッジコンピューティング環境のコンテナデプロイメントシステムにおいて、デプロイ元の端末がデプロイ先のコンテナデプロイ

Latona, Inc. 3 Nov 5, 2021
Containerize a python web application

containerize a python web application introduction this document is part of GDSC at the university of bahrain you don't need to follow along, fell fre

abdullah mosibah 1 Oct 19, 2021
A simple python application for running a CI pipeline locally This app currently supports GitLab CI scripts

?? Simple Local CI Runner ?? A simple python application for running a CI pipeline locally This app currently supports GitLab CI scripts ⚙️ Setup Inst

Tom Stowe 0 Jan 11, 2022
A Python Implementation for Git for learning

A pure Python implementation for Git based on Buliding Git

shidenggui 42 Jul 13, 2022
A repository containing a short tutorial for Docker (with Python).

Docker Tutorial for IFT 6758 Lab In this repository, we examine the advtanges of virtualization, what Docker is and how we can deploy simple programs

Arka Mukherjee 0 Dec 14, 2021
Simple ssh overlay for easy, remote server management written in Python GTK with paramiko

Simple "ssh" overlay for easy, remote server management written in Python GTK with paramiko

kłapouch 3 May 1, 2022
Build and Push docker image in Python (luigi + docker-py)

Docker build images workflow in Python Since docker hub stopped building images for free accounts, I've been looking for another way to do it. I could

Fabien D. 2 Dec 15, 2022