cronsim
Cron expression parser and evaluator
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 cronsimuv
uv add cronsimpoetry
poetry add cronsimInstalling 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
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
cronexEvaluates cron expressions to determine if a…
permissive · top 15,000 on PyPI
crontabParses crontab schedule expressions and…
copyleft · top 5,000 on PyPI
cron-validatorValidates Unix cron expressions, matches them…
permissive · top 5,000 on PyPI
cronitercroniter iterates over datetime objects using…
permissive · top 1,000 on PyPI
quartz-cron-checkerValidates Quartz-style cron expressions against…
unclear · top 15,000 on PyPI
cron-converterParses cron schedule strings into structured…
permissive · top 5,000 on PyPI
aws-cron-expression-validatorValidates AWS EventBridge cron expressions,…
permissive · top 15,000 on PyPI
pycronParses cron-style schedule strings and…
permissive · top 5,000 on PyPI
aws-croniterParses, validates, and calculates occurrences…
permissive · top 15,000 on PyPI
pyawscronParses and iterates over AWS CloudWatch cron…
permissive · top 15,000 on PyPI