Cron Schedule Triggers

0.0.11 · maintenance · verified Thu Apr 16

Cron Schedule Triggers (CSTriggers) is a Python library (version 0.0.11) for determining future execution dates based on Quartz Job Scheduler cron syntax. It is not a scheduler itself, but a utility to calculate trigger dates for integration into other scheduling systems. The last release was in November 2019, suggesting a maintenance-level activity rather than active development.

Common errors

Warnings

Install

Imports

Quickstart

Initializes a `QuartzCron` object with a cron string and start/end dates, then retrieves the next scheduled trigger date. Note the use of `datetime` objects for date parameters and the 7-field Quartz cron syntax.

from datetime import datetime
from cstriggers.core.trigger import QuartzCron

# Example: Every day, every hour, on the 0th minute and 0th second
# using Quartz Cron Syntax (seconds, minutes, hours, day-of-month, month, day-of-week, year)
# '?' means no specific value for that field to avoid conflicts (e.g., between day-of-month and day-of-week)
schedule_string = "0 0 * * * ? *"

# Define start and (optional) end dates as datetime objects
start_date = datetime(2023, 1, 1, 0, 0, 0)
end_date = datetime(2024, 1, 1, 0, 0, 0) # Inclusive end

# Initialize the cron object
cron_obj = QuartzCron(schedule_string=schedule_string, start_date=start_date, end_date=end_date)

# Get the next trigger date
next_trigger_date = cron_obj.next_trigger()
print(f"Next trigger: {next_trigger_date.isoformat()}")

# Get multiple trigger dates
print("\nUpcoming 3 triggers:")
for _ in range(3):
    next_trigger = cron_obj.next_trigger()
    if next_trigger:
        print(next_trigger.isoformat())
    else:
        print("No more triggers within the specified range.")
        break

view raw JSON →