ajyadav013/claude-kit/cron-and-scheduled-jobs
Claude Code and agent skill by ajyadav013/claude-kit
- community
Checking that the SKILL.md file is still in the repository.
Scheduled jobs across two mechanisms — Kubernetes CronJobs (schedule in Helm values, MODE=cron) and Temporal Schedules. Use when adding periodic jobs or choosing between k8s and Temporal.
Install
npx vskill@latest install ajyadav013/claude-kit/cron-and-scheduled-jobsSKILL.md
The same SKILL.md was published earlier as ajyadav013/claude-kit/cron-and-scheduled-jobs.
Cron & Scheduled Jobs
Two mechanisms run recurring work in this stack, and they put the schedule in two very different places. Knowing which one you're in tells you where the schedule lives and what owns the recurrence:
- Kubernetes CronJob — the cluster's
CronJobcontroller is the scheduler. It fires a fresh pod
on the schedule; the pod runs the same service image booted in a one-shot MODE=cron that executes a single named job from a Python registry and exits. The schedule lives in Helm values, never in the app.
- Temporal Schedule — the Temporal server is the durable scheduler. A
Scheduleobject fires
a workflow on a cron expression or interval; a missed window, catch-up, pause, and backfill are all first-class. The schedule lives in a registration step (run once / idempotently on deploy).
Companion skills:temporal-config-driven(workflow/activity/worker mechanics, retries, idempotency,and the deeper schedule-registration reference — this skill cross-links it rather than repeating it),containerization-and-deployment(theMODE-dispatch entrypoint and Helm packaging),kubernetes-workload-hardening(securityContext/NetworkPolicy for the CronJob pod), andobservability-and-logging(the cron execution metric).
When to use
- Adding a periodic / scheduled job to a service and deciding where the schedule belongs
- Wiring a `MODE=cron` entrypoint and registering a job in the Python cron registry
- Declaring a CronJob in Helm values (
Cronsblock) and understanding the rendered manifest - Registering or updating a Temporal Schedule (cron vs interval, overlap, pause-on-failure)
- Deploying schedule registration as a one-shot k8s `Job`
- Choosing between a Kubernetes CronJob and a Temporal Schedule
- Debugging "the job didn't run", overlapping runs, timezone drift, or piled-up executions
Two mechanisms at a glance
| Kubernetes CronJob + `MODE=cron` | Temporal Schedule | ||
|---|---|---|---|
| Scheduler | k8s CronJob controller | Temporal server | |
| Where the schedule lives | Helm values.yaml → Crons.<name>.Schedule | a registration step (create_schedule) | |
| What runs | one-shot pod: MODE=cron CRON_JOB=<name> → registry handler → exit | a Temporal workflow | |
| Recurrence units | 5-field cron only | cron or interval (every= + offset=) | |
| Overlap control | concurrencyPolicy: Forbid (coarse) | ScheduleOverlapPolicy.SKIP/BUFFER_ONE/... (rich) | |
| Missed-run visibility | none (the pod just didn't run) | first-class (server tracks it) | |
| Pause / backfill / manual fire | suspend the CronJob (no backfill) | pause/unpause/backfill/trigger | |
| Retry across fires | none (pod exits; next fire is fresh) | per-fire pause_on_failure + workflow RetryPolicy | |
| Best for | simple, self-contained periodic app tasks | durable/long jobs needing overlap, catch-up, visibility |
Core conventions
Kubernetes CronJob + MODE=cron
The schedule is config, not code. You declare a cron under the service's Crons block in Helm values; the chart renders one kind: CronJob per entry. The job's only app-side coupling is two env vars — MODE=cron and CRON_JOB=<name> — that tell the shared image which single job to run.
The rendered CronJob carries sensible defaults from the chart: concurrencyPolicy: Forbid, failedJobsHistoryLimit: 3, successfulJobsHistoryLimit: 1, restartPolicy: Never, ttlSecondsAfterFinished: 300. The chart has no `timeZone` and no `startingDeadlineSeconds` — so the schedule evaluates in the cluster's timezone (usually UTC) and a controller that's down past a fire window silently skips it. Plan around both (see references/choosing-and-operations.md).
The app side is a one-shot dispatcher, not a daemon. A multi-mode entrypoint.py reads MODE; the cron branch runs a single job from a registry and the process exits. There is no in-process scheduler or loop — k8s owns the cadence.
The registry maps a name to a handler. Two shapes are common — a plain name → async callable, or a richer name → {task, description, schedule}. In the rich shape the schedule field is documentation only; the authoritative schedule is the Helm Crons entry. Keep them in sync by convention (the registry comment should point at the Helm values).
Conventions that matter for CronJobs:
- Idempotency is the job's responsibility.
concurrencyPolicy: Forbidprevents overlap, not
re-runs — a retried/late fire may reprocess the same window. Make the handler safe to run twice (upsert, watermark/cursor, or a dedupe key).
- Exit non-zero on failure.
restartPolicy: Never+ a raised exception marks the Job failed and
surfaces in failedJobsHistoryLimit. Don't swallow the exception.
- Handle SIGTERM for a graceful stop on pod eviction/rollout.
- Emit the execution metric (
record_cron_job_executed(name, status, duration)) so cron health is
observable — see observability-and-logging.
Temporal Schedule
When the work is already a Temporal workflow, or needs durability / overlap control / catch-up / visibility, let the Temporal server own the recurrence with a Schedule. The workflow/activity mechanics live in temporal-config-driven; this skill covers the scheduling dimension.
Prefer an interval spec over a cron expression for daily-ish cadences. Temporal evaluates cron_expressions in UTC by default (the chart/clients here don't set time_zone), so ["0 9 * * *"] fires at 09:00 UTC, not local. An interval with an offset is timezone-explicit and avoids the foot-gun:
Register idempotently, and run it as a one-shot Job. Build the schedule from the spec above plus an action and policy, then register it safely:
Registration is a deploy step, not worker startup — a separate one-shot k8s kind: Job (not a CronJob) runs python -m <pkg>.schedules ensure after the worker Deployment is up, writing the schedule into Temporal, which then fires it. The full create-or-update loop, the CLI, and the lifecycle helpers (pause/unpause/delete/update) are owned by the `temporal-config-driven` skill; the Job manifest, the interval/overlap details, and the manual-trigger snippet are in references/temporal-schedules.md.
Choosing between them
- Kubernetes CronJob when the task is a simple, self-contained periodic job, runs to completion in
one shot, and Forbid overlap is enough. Lowest moving parts; the schedule is plain Helm config.
- Temporal Schedule when the job is long or durable, needs overlap policy finer than Forbid,
catch-up / backfill, per-fire pause-on-failure, missed-run visibility, or is already a Temporal workflow. The server gives you scheduling observability a CronJob can't.
Don't run both for the same job (double fires). See references/choosing-and-operations.md for the full decision matrix and the timezone/overlap/history details.
Skeleton / example
A "nightly report" job, shown both ways. Pick one — they're alternatives, not layers.
See references/kubernetes-cronjob.md and references/temporal-schedules.md for the complete, copy-ready versions of each.
Anti-patterns to avoid
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cron-and-scheduled-jobs/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/ajyadav013/claude-kit/cron-and-scheduled-jobs)