Cron Expression Mastery
5minTL;DR: Build, test, and understand cron expressions for scheduling tasks across Linux, Kubernetes, and cloud platforms.
Cron is the time-based job scheduler in Unix-like systems. A cron expression defines when a task should run using a compact five-field format: minute, hour, day of month, month, day of week.
Each field supports exact values (5), ranges (1-5), lists (1,3,5), steps (1-10/2), and wildcards (*). The five fields create 525,600 possible combinations per year, but only a fraction are practical.
Common patterns: */5 * * * * (every 5 minutes), 0 * * * * (every hour), 0 0 * * * (daily at midnight), 0 9 * * 1-5 (weekdays at 9 AM), 0 0 1 * * (first day of month), 0 0 * * 0 (weekly on Sunday).
Gotchas: cron uses the server timezone. Day-of-week 0 and 7 both mean Sunday. If both day-of-month and day-of-week are specified (not *), the task runs when EITHER matches. Minute granularity is the finest available, no seconds support.
Kubernetes CronJobs use the same format but require an additional timezone field (starting v1.25). AWS EventBridge, Google Cloud Scheduler, and Azure Scheduler all support cron-like expressions with minor variations.
Use the devvkit Cron Expression Generator to visually build and test your schedules. The visual timeline makes it easy to verify your expression behaves as expected.
Build, test, and understand cron expressions for scheduling tasks across Linux, Kubernetes, and cloud platforms.