convex-cron-jobs
Scheduled function patterns for background tasks including interval scheduling, cron expressions, job monitoring, retry strategies, and best practices for long-running tasks
By waynesutton · 2,674 installs
npx skills add waynesutton/convexskills --skill convex-cron-jobs
Source repository · Upstream listing
Convex Cron Jobs
Schedule recurring functions for background tasks, cleanup jobs, data syncing, and automated workflows in Convex applications.
Documentation Sources
Before implementing, do not assume; fetch the latest documentation:
Primary: https://docs.convex.dev/scheduling/cron jobs
Scheduling Overview: https://docs.convex.dev/scheduling
Scheduled Functions: https://docs.convex.dev/scheduling/scheduled functions
For broader context: https://docs.convex.dev/llms.txt
Instructions
Cron Jobs Overview
Convex cron jobs allow you to schedule functions to run at regular intervals or specific times. Key features:
Run functions on a fixed schedule
Support for interval based and cron expression scheduling
Automatic retries on failure
Monitoring via the Convex dashboard
Basic Cron Setup
Interval Based Scheduling
Use crons.interval for simple recurring tasks:
Cron Expression Scheduling
Use crons.cron for precise scheduling with cron expressions:
Cron Expression Reference
Common patterns:
Every minute
0 Every hour
0 0 Every day at midnight
0 0 0 Every Sunday at midnight
0 0 1 First day of every month
/5 Every 5 minutes
0 9 17 1 5 Every hour from 9 AM to 5 PM, Monday through Friday
Internal Functions for Crons
Cron jobs should call internal functions for security:
Cron Jobs with Arguments
Pass static arguments to cron jobs:
Monitoring and Logging
Add logging to track cron job execution:
Batching for Large Datasets
Handle large datasets in batches to avoid timeouts:
External API Calls in Crons
Use actions for external API calls:
Examples
Schema for Cron Job Logging
Complete Cron Configuration Example
Best Practices
Never run npx convex deploy unless explicitly instructed
Never run any git commands unless explicitly instructed
Only use crons.interval or crons.cron methods, not deprecated helpers
Always call internal functions from cron jobs for security
Import internal from generated/api even for functions in the same file
Add logging and monitoring for production cron jobs
Use batching for operations that process large datasets
Handle errors gracefully to prevent job failures
Use meaningful job names for dashboard visibility
Consider timezone when using cron expressions (Convex uses UTC)
Common Pitfalls
1. Using public functions Cron jobs should call internal functions only
2. Long running mutations Break large operations into batches
3. Missing error handling Unhandled errors will fail the entire job
4. Forgetting timezone All cron expressions use UTC
5. Using deprecated helpers Avoid crons.hourly , crons.daily , etc.
6. Not logging execution Makes debugging production issues difficult
References
Convex Documentation: https://docs.convex.dev/
Convex LLMs.txt: https://docs.convex.dev/llms.txt
Cron Jobs: https://docs.convex.dev/scheduling/cron jobs
Scheduling Overview: https://docs.convex.dev/scheduling
Scheduled Functions: https://docs.convex.dev/scheduling/scheduled functions