Python | Schedule Library

Last Updated : 17 Jul, 2026

Schedule library is a Python library used to automate tasks at specific time intervals or scheduled times. It allows to run Python functions periodically using a simple and readable syntax, making it useful for automating repetitive tasks such as sending emails, generating reports, backing up files, or executing scripts at fixed intervals.

Installation 

Before using the library, install it using pip:

pip install schedule

The library works by continuously checking for pending scheduled jobs and executing them when their scheduled time is reached.

schedule.Job Class

Job class represents a scheduled task in the Schedule library. It stores information such as the execution interval, scheduling time and function that should be executed. A Job object is created automatically when you use methods like schedule.every().

schedule.Job(interval, scheduler=None)

Parameters:

  • interval: Specifies how often the job should run (for example, every 5 minutes or every 2 hours).
  • scheduler (optional): The scheduler instance that manages the job.

Common Job Methods

  • at(time_str): Runs the job at a specific time (for example, "09:30").
  • do(job_func, *args, **kwargs): Assigns the function that should be executed.
  • run(): Executes the job immediately and schedules the next run.
  • to(latest): Runs the job at a random interval between two values (for example, every 5 to 10 minutes).
  • tag(*tags): Assigns one or more tags to a job for easier management.
  • until(time): Schedules the job to stop running after a specified date or time.
  • cancel(): Removes the scheduled job.

Scheduling Different Types of Jobs

The following example demonstrates different ways to schedule tasks, such as running a function every few minutes, every hour, on a specific day, or at a particular time.

Python
import schedule
import time

def reminder():
    print("Take a short break!")

def backup():
    print("Creating backup...")

def report():
    print("Generating daily report...")

def meeting():
    print("Weekly team meeting")

schedule.every(10).minutes.do(reminder)
schedule.every().hour.do(backup)
schedule.every().day.at("18:00").do(report)
schedule.every().monday.at("09:00").do(meeting)
schedule.every(5).to(10).minutes.do(reminder)

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

Output

Take a short break!
Creating backup...
Generating daily report...
Weekly team meeting
...

Explanation:

  • Defines multiple functions to be executed automatically.
  • Schedules jobs at different intervals, including minutes, hours, days, and weekdays.
  • Uses schedule.run_pending() to check whether any scheduled job is ready to execute.
  • Keeps the scheduler running continuously using an infinite loop.

Managing Scheduled Jobs

The Schedule library also allows you to view, tag, and cancel scheduled jobs, making it easier to manage multiple tasks in larger applications.

Python
import schedule

def greet():
    print("Hello!")

job = schedule.every().minute.do(greet).tag("greeting")
print(schedule.get_jobs())

schedule.clear("greeting")
print(schedule.get_jobs())

Output

[Every 1 minute do greet() (last run: [never], next run: 2026-07-09 17:10:09)]
[]

Explanation:

  • Creates a job that runs every minute.
  • Assigns the tag "greeting" to the job.
  • Displays all scheduled jobs using schedule.get_jobs().
  • Removes the tagged job using schedule.clear("greeting").
  • Prints the updated job list, which is empty after removal.
Comment