Task Scheduling (Cron)
Use TaskSchedule to create recurring run tasks from a task template.
Purpose
TaskSchedule evaluates a 5-field cron expression and creates a new Task run from a template task (spec.mode=template).
Before You Begin
orlojdis running (scheduler/controller active).- At least one worker is available for execution.
- The target
Tasktemplate exists and setsspec.mode: template.
1. Apply a Task Template
go run ./cmd/orlojctl apply -f examples/resources/tasks/weekly_report_template_task.yamlTemplate reference used by schedules:
metadata.name:weekly-report-templatespec.mode:template
2. Apply a Schedule
Example schedule resource:
Apply it:
go run ./cmd/orlojctl apply -f examples/resources/task-schedules/weekly_report_schedule.yamlKey fields:
spec.task_ref: template task name (nameornamespace/name)spec.schedule: 5-field cron expression (for example,0 9 * * 1)spec.time_zone: IANA timezone (for example,America/Chicago)spec.concurrency_policy: v1 supportsforbidspec.starting_deadline_seconds: lateness window before a missed slot is skipped
3. Verify Schedule State
List schedules:
go run ./cmd/orlojctl get task-schedulesInspect schedule status directly:
curl -s "http://127.0.0.1:8080/v1/task-schedules/weekly-report?namespace=default" | jq .statusImportant status fields:
nextScheduleTimelastScheduleTimelastTriggeredTaskactiveRuns
4. Verify Triggered Run Tasks
go run ./cmd/orlojctl get tasksGenerated run tasks are labeled with schedule metadata:
orloj.dev/task-scheduleorloj.dev/task-schedule-namespaceorloj.dev/task-schedule-slot
Common Controls
- Pause scheduling: set
spec.suspend: true - Resume scheduling: set
spec.suspend: false - Retention: tune
successful_history_limitandfailed_history_limit
Troubleshooting
- If no tasks are created, verify
spec.task_refpoints to an existing template task. - If schedule status is
Error, inspect.status.lastErrorand timezone/cron syntax. - If runs are skipped, check
starting_deadline_secondsandconcurrency_policybehavior.