- Home
- Skills
- Waynesutton
- Convexskills
- Convex Cron Jobs
convex-cron-jobs_skill
- JavaScript
225
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill waynesutton/convexskills --skill convex-cron-jobs- SKILL.md13.6 KB
Overview
This skill provides production-ready patterns for scheduling recurring background work in Convex applications. It covers interval and cron-expression scheduling, secure internal handlers, retry behavior, monitoring, and batching strategies to handle large datasets. Use these patterns to run cleanup tasks, data syncs, reports, and health checks reliably in UTC.
How this skill works
Define cron jobs with two primitives: crons.interval for simple intervals and crons.cron for cron expressions. Jobs call internal functions or actions for security and side effects; long work is split into batched internal mutations and scheduled continuation runs. Built-in retry behavior and dashboard monitoring let you log start/end times, processed counts, errors, and status for each run.
When to use it
- Regular cleanup of expired sessions, temp files, or logs
- Periodic data syncs with external APIs or other services
- Scheduled reports and analytics generation (daily, weekly, monthly)
- Frequent health checks and monitoring tasks
- Processing large queues by batching and scheduling follow-up runs
Best practices
- Always invoke internal functions from cron jobs for security
- Use batching and scheduler.runAfter to avoid long-running mutations
- Add structured logging and insert cronLogs records for observability
- Use UTC-aware cron expressions and choose clear, descriptive job names
- Handle errors explicitly and record partial failures to avoid silent drops
- Prefer crons.interval and crons.cron; avoid deprecated helpers
Example use cases
- Hourly cleanup that deletes expired sessions and logs processed counts
- Every-15-minute sync that fetches external API data via an action, then stores it with a mutation
- Daily midnight report generator that inserts analytics into a reports table
- Batch processor that paginates pending tasks and schedules subsequent batches via runAfter
- Frequent health check running every 30 seconds to monitor service status
FAQ
Always call internal functions or actions. Internal handlers restrict access and reduce security risks when running scheduled work.
How do I handle very large datasets in a cron job?
Process items in batches (e.g., 100 items), update a cursor, and schedule the next batch with ctx.scheduler.runAfter to avoid timeouts and long transactions.