larzcron
Cron expressions and an in-process scheduler. Pure Python, zero dependencies.
Parse and match standard cron expressions, compute the next/previous fire time, and run jobs on cron schedules or fixed intervals — all in-process, with no daemon, no service, and nothing to install.
from larzcron import CronExpression
from datetime import datetime
c = CronExpression("*/15 9-17 * * mon-fri") # every 15 min, 9-5, weekdays
c.matches(datetime(2026, 7, 27, 9, 30)) # True
c.next(datetime(2026, 7, 27, 9, 31)) # -> 2026-07-27 09:45
Why
- Zero dependencies. No
croniter, noAPScheduler, no service to run — just the standard library. - Full everyday cron syntax.
*, ranges (1-5), lists (1,3,5), steps (*/15,0-30/10), three-letter names (mon,jan), Sunday as0or7, and macros (@daily,@hourly,@weekly,@monthly,@yearly). It even honours the Vixie-cron rule where a restricted day-of-month or day-of-week matches. - Answers the real questions.
matches(dt),next(after),previous(before)— parse a schedule and know exactly when it fires. - A scheduler when you want one. Register cron and interval jobs and either
run a background thread or drive it deterministically with
run_pending(now)(perfect for tests and cron/lambda-style ticks).
Install
pip install larzcron
Expressions
CronExpression("0 * * * *") # top of every hour
CronExpression("*/15 * * * *") # every 15 minutes
CronExpression("0 9-17 * * mon-fri")
CronExpression("0 0 1,15 * *") # 1st and 15th at midnight
CronExpression("@daily") # macros
c.matches(dt) # bool
c.next(after) # next datetime strictly after `after`
c.previous(before) # previous matching datetime
Scheduler
from larzcron import Scheduler
sched = Scheduler()
@sched.cron("0 * * * *") # hourly
def rollup():
...
@sched.every(30) # every 30 seconds
def heartbeat():
...
sched.start() # background daemon thread; sched.stop() to end
For tests and cron-driven environments, tick it yourself — deterministic, no threads:
sched.run_pending(now=some_datetime) # fires whatever is due at `now`
Add an on_error=lambda job, exc: ... handler to catch job exceptions without
stopping the scheduler.
Tests
python -m unittest discover -s tests -v # 27 tests, zero deps
The Larz stack
Pure-Python, zero-dependency building blocks: larz · larzchain · larzmoney · larzcrypt · larzdb · larzagent · larzchart · larzmark · larztask · larzvault · larzvm · larzcache · larzvalidate · larzid · larzrpc · larzstate · larzhttp · larzconf · larzcron
License
MIT © larz-scripter
Metadata
Release files for larzcron 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| larzcron-0.1.0.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| larzcron-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.4 kB
Release files / larzcron-0.1.0.tar.gz
| Download URL | larzcron-0.1.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
88fd2eabd5154d200203b57ad6cae346be3203fab0f9a1ba80645cffe60564d4
|
|
BLAKE2b-256 checksum How to use checksums |
7fe91742d6fd4f668ab5ef4ba243442d43fb8dd3ff589fcdac510cede10579c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / larzcron-0.1.0-py3-none-any.whl
| Download URL | larzcron-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f965a3e8d0d05eef9c2bd26eae70d2662a52f46e375fae5bf8c521ed5d1c9f1
|
|
BLAKE2b-256 checksum How to use checksums |
a6267304b87304d2adec96f5cd3dda08a0665486591650ebd781672c4cceee33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|