Steps to Set Up Scheduled Jobs
Overview
Scheduled jobs run scripts at specific times. Configure them in config/config.json.
Steps
1. Create Script
Place your script in the scripts/ folder:
- Python scripts:
.py(e.g.,scripts/my_script.py) - Bash scripts:
.sh(e.g.,scripts/my_script.sh)
For bash scripts, make them executable:
chmod +x scripts/my_script.sh2. Add Job to config.json
Edit config/config.json and add under scheduler.jobs:
{
"name": "job_name",
"schedule": "0 * * * *",
"script": "scripts/my_script.py",
"args": [],
"enabled": true,
"requires_approval": false,
"description": "What the job does"
}Cron Schedule Format
minute hour day month weekday| Field | Range | Examples |
|---|---|---|
| minute | 0-59 | 0, */5, 0,30 |
| hour | 0-23 | 9, 9,11,13, 9-17 |
| day | 1-31 | 1, 1,15 |
| month | 1-12 | *, 1,4,7 |
| weekday | 0-7 | 0,6 (0=Sunday) |
Common Examples
| Schedule | Runs |
|---|---|
*/5 * * * * |
Every 5 minutes |
0 * * * * |
Every hour at :00 |
0 9 * * * |
Daily at 9:00 AM |
0 9,17 * * * |
Daily at 9 AM and 5 PM |
0 9,11,13,15,17,19 * * * |
Every 2 hours (9AM-7PM) |
0 9 * * 1-5 |
Weekdays at 9 AM |
30 9 * * * |
Daily at 9:30 AM |
Enable Scheduler
Make sure scheduler.enabled is true in config.json:
"scheduler": {
"enabled": true,
"poll_interval_seconds": 60,
...
}Testing
Run Manually
python -m orchestrator.cli scheduler run-dueList Jobs
python -m orchestrator.cli scheduler listRun in Loop
python -m orchestrator.cli scheduler loop --interval 60Example Jobs
Python Script (list_files.py)
#!/usr/bin/env python3
from pathlib import Path
def main():
files = sorted([f.name for f in Path(".").iterdir() if f.is_file()])
Path("filelist.txt").write_text("\n".join(files))
print(f"Wrote {len(files)} files")
if __name__ == "__main__":
main()Bash Script (check_diskspace.sh)
#!/bin/bash
echo "=== Disk Space Check ==="
df -h /
echo "=== Done ==="Fields Reference
| Field | Required | Description |
|---|---|---|
| name | Yes | Unique job identifier |
| schedule | Yes | Cron expression |
| script | Yes | Path to script (relative to project root) |
| args | No | Command line arguments |
| enabled | Yes | Set to true to run |
| requires_approval | No | Set to true for risky jobs |
| description | No | Human-readable description |