skillfed

cronsim

Cron expression parser and evaluator

cronsim v2.7 14.7M downloads/30d#1,219 on PyPI81
Permissive license AGING released

What it is and what it does

CronSim is a cron expression parser and evaluator that takes a cron schedule string and a starting datetime, then generates the sequence of datetimes when that schedule would execute. It's designed to match Debian's cron implementation closely, including its handling of Daylight Saving Time transitions and quirky edge cases. The package prioritizes correctness over feature breadth, implementing only the syntax that its primary user (the Healthchecks monitoring service) requires.

You instantiate a CronSim object with an expression and a datetime, then iterate forward or backward through matching times using Python's iterator protocol. It supports standard five-field cron syntax plus an optional sixth field for seconds, and several non-standard extensions like "L" for last-day-of-month, "LW" for last-weekday, and "MON#5" for nth-weekday-of-month. Invalid expressions raise CronSimError; expressions with no match within 50 years raise StopIteration. Starting from version 2.4, it includes an explain() method to generate human-readable descriptions of expressions.

Use it for:

  • Calculate upcoming execution times for a cron job to display in a monitoring dashboard or alert system.
  • Validate cron expressions and provide user-friendly error messages when syntax is invalid.
  • Iterate backward in time to find when a job last ran, for audit or debugging purposes.
  • Generate a text description of a cron schedule for documentation or UI display.
  • Handle DST transitions correctly when scheduling jobs across timezone boundaries.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Parses and evaluates cron expressions to find matching execution times, with support for Debian cron syntax including DST handling, optional seconds field, and advanced features like last-day-of-month and nth-weekday matching.

Yes. CronSim is a focused, well-maintained library with zero dependencies, permissive licensing, and no known vulnerabilities. Install it if you need to parse or evaluate cron expressions in Python—particularly if you require Debian cron compatibility or advanced features like last-day-of-month matching. The aging maintenance status is not a concern given the stable, narrow scope of the package.

Install

cronsim on PyPI

pip

pip install cronsim

uv

uv add cronsim

poetry

poetry add cronsim

Installing cronsim

Before you install

Low friction: pure Python wheel with no runtime dependencies. Maintenance is aging (297 days since last release), but the package is marked Production/Stable and the repository remains active with recent commits.

License in practice

Permissive license (BSD) means you can use, modify, and redistribute the package with minimal restrictions, typical for open-source libraries.

Quickstart

from datetime import datetime
from cronsim import CronSim

it = CronSim("0 0 * 2 MON#5", datetime(2020, 1, 1))
for x in range(0, 5):
    print(next(it))

Requires Python 3.10 or later.

Verify before relying

  • Whether the package's DST handling matches your timezone library's behavior in edge cases.
  • Performance characteristics when iterating over very long time ranges or complex expressions.

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 297 days since the last release
Last repo commit
First released
Downloads 14,674,924/month — #1,219 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: cronsim-2.7-py3-none-any.whl

Keywords: cron, cronjob, crontab, schedule

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Topic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

cron expression parsercron schedule evaluatorcrontab expression matcherjob scheduling time calculatorcron syntax validator
cron-schedulingtime-expression-parsing

More Python Modules packages