Page tree

The "schedule" package in Python is a simple and intuitive library used for scheduling tasks and executing them at specified intervals or times. It provides a convenient way to create and manage recurring tasks or jobs within a Python program.  It is a alternative to using a cron-based scheduler for tasks and can be supported under the Gadi Persistent Sessions.

Key features of the "schedule" package include:

  1. Task Scheduling: Allows you to schedule tasks to run at specific times or intervals.

  2. Simple Syntax: Provides an easy-to-understand syntax for setting up schedules using human-readable expressions.

  3. Recurring Jobs: Supports recurring jobs based on time, allowing tasks to be executed hourly, daily, weekly, or at custom intervals.

  4. Thread Safety: Provides thread safety mechanisms for handling concurrent scheduling and execution of tasks.

  5. Callback Support: Enables the execution of custom functions or callbacks when a scheduled task is due.

Run the following commands to load it at Gadi login node or the persistent session ( you need to join project hr22 firstly)

module use /g/data/hr22/modulefiles
module load schedule/1.2.0

Example usage of the "schedule" package might include:

import schedule
import time

def task():
    print("Executing task...")

# Schedule a task to run every 2 hours

# Schedule a daily task at a specific time

# Execute scheduled tasks
while True:

This code demonstrates how to schedule tasks to run at specific intervals or times using the "schedule" package. It defines a task to be executed and schedules it to run every 2 hours and daily at 10:00 AM.

You can find more examples under "$SCHEDULE_ROOT/test".

You can also run it in the background as shown here.

  • No labels