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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file larzcron-0.1.0.tar.gz.
File metadata
- Download URL: larzcron-0.1.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88fd2eabd5154d200203b57ad6cae346be3203fab0f9a1ba80645cffe60564d4
|
|
| MD5 |
4a59ab437934f9d7075dee43254f2af7
|
|
| BLAKE2b-256 |
7fe91742d6fd4f668ab5ef4ba243442d43fb8dd3ff589fcdac510cede10579c4
|
File details
Details for the file larzcron-0.1.0-py3-none-any.whl.
File metadata
- Download URL: larzcron-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f965a3e8d0d05eef9c2bd26eae70d2662a52f46e375fae5bf8c521ed5d1c9f1
|
|
| MD5 |
b38e3707976f4fe443e173869edd18d4
|
|
| BLAKE2b-256 |
a6267304b87304d2adec96f5cd3dda08a0665486591650ebd781672c4cceee33
|