37
AutomationCron Jobs
Schedule recurring jobs that run inside SapixDB — no external scheduler required.
Prerequisite: Lesson 5 complete
What you'll learn
- ✓POST /v1/agents/:id/crons — name, schedule (5-field cron), action
- ✓action types: write to an agent, call a webhook
- ✓GET /v1/agents/:id/crons — list crons
- ✓DELETE /v1/agents/:id/crons/:name — remove
- ✓Standard cron expressions: * * * * * (every minute) to 0 0 1 * * (monthly)
Challenge
Create a cron that writes a heartbeat record every minute. Wait 3 minutes. Verify 3 records were written.
Interactive Walkthrough
What you'll learn
Schedule recurring jobs that run inside SapixDB — no external scheduler required.
Create a cron job
curl -s -X POST http://localhost:7475/v1/agents/jobs/crons \
-H "Content-Type: application/json" \
-H "Authorization: Bearer spx_root_YOUR_ROOT_KEY" \
-d '{
"name": "daily-report",
"schedule": "0 9 * * *",
"action": {
"type": "write",
"agent_id": "reports",
"payload": {"type": "daily_summary", "generated_by": "cron"}
}
}' | python3 -m json.toolList crons
curl -s http://localhost:7475/v1/agents/jobs/crons \
-H "Authorization: Bearer spx_root_YOUR_ROOT_KEY" \
| python3 -m json.toolDelete a cron
curl -s -X DELETE http://localhost:7475/v1/agents/jobs/crons/daily-report \
-H "Authorization: Bearer spx_root_YOUR_ROOT_KEY"Cron schedule format (standard 5-field)
| Field | Values |
|---|---|
| minute | 0–59 |
| hour | 0–23 |
| day of month | 1–31 |
| month | 1–12 |
| day of week | 0–7 (0=Sunday) |
Examples:
- * * * * * — every minute
- 0 * * * * — every hour
- 0 9 * * 1 — every Monday at 09:00
- 0 0 1 * * — first day of every month
Challenge
Create a cron that writes a heartbeat record to a heartbeats agent every minute. Wait 3 minutes. Verify 3 records were written.
---