Task Scheduler
In-process job scheduler with interval, cron, and one-shot triggers, priority run queue, concurrency limits, retry with backoff, missed-run policies, and state persistence.
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 11 files
📖 Documentation Preview README excerpt
Task Scheduler
An in-process job scheduler built on Python stdlib. Schedule tasks by fixed interval, cron expression (5-field, with full wildcard/step/range/list syntax), or as a one-shot at a specific datetime. Features a priority-based run queue, configurable concurrency limits, retry with exponential backoff, missed-run policies, and automatic state persistence to JSON.
Features
- Cron expressions — Full 5-field parser supporting
,/n,a-b,a,b,c, and combinations - Interval scheduling — Run tasks every N seconds with drift-free tracking
- One-shot tasks — Fire once at a specified datetime, then never again
- Priority queue — Higher-priority tasks run first when multiple are due simultaneously
- Concurrency control — Cap the number of tasks running in parallel via thread semaphore
- Retry with backoff — Failed tasks retry up to N times with configurable exponential delay
- Missed-run policy — Choose
catch_up(fire immediately on overdue) orskip(wait for next window) - State persistence — Schedule state and last-run timestamps survive restarts via JSON file
- Built-in demo tasks —
heartbeat,disk_usage, andcleanup_tmpfor testing without shell commands - Single-tick mode —
--onceruns one scheduler pass and exits (ideal for testing and cron-driven invocation)
Requirements
- Python 3.10+
- No external dependencies (stdlib only)
Quick Start
# Show all CLI options
python src/task_scheduler.py --help
# List tasks with their next scheduled fire times
python src/task_scheduler.py --config examples/task_scheduler_config.json --list
# Run a single scheduler tick (fires due tasks, then exits)
python src/task_scheduler.py --config examples/task_scheduler_config.json --once
# Start the daemon loop (Ctrl-C to stop)
python src/task_scheduler.py --config examples/task_scheduler_config.json
# Override state file location and log level
python src/task_scheduler.py --config examples/task_scheduler_config.json --state-file /tmp/state.json --log-level DEBUG
Configuration Reference
CLI Options
| Flag | Default | Description |
|---|---|---|
--config, -c | (required) | Path to the JSON schedule config file |
--once | false | Execute a single scheduler tick then exit |
--list | false | Print every task with its next fire time and exit |
--state-file | <config_dir>/scheduler_state.json | Override the state-file path |
--log-level | INFO | Logging verbosity (DEBUG, INFO, WARNING, ERROR) |
Cron Syntax
Standard 5-field format: minute hour day-of-month month day-of-week
| Field | Range | Examples |
|---|---|---|
| Minute | 0–59 | 0, */5, 0,15,30,45 |
... continues with setup instructions, usage examples, and more.