pg_cron.
Overview
Schedules trigger your Functions at specified intervals — useful for recurring tasks like data cleanup, report generation, and external API syncing.Technology Stack
How It Works
- Create a function to run on schedule
- Define a cron expression for the timing
- Yboard registers the schedule with
pg_cron - The function is invoked automatically at each interval
Execution Flow
pg_cronfires at the scheduled time- PostgreSQL trigger calls the function endpoint
- Function executes with admin-level access
- Results are logged for monitoring
Cron Expressions
Standard cron syntax with 5 fields:Common Patterns
Secret Management
Scheduled functions can access secrets configured in your project. Use them for API keys, database URLs, and other sensitive values.Best Practices
- Keep schedules idempotent — Functions should be safe to re-run
- Use appropriate intervals — Don’t schedule more frequently than needed
- Add error handling — Log failures for debugging
- Monitor execution — Check logs regularly for issues
Limitations
- Minimum interval is 1 minute
- Maximum execution time follows function limits (30 seconds)
- All times are in UTC