🍋
Menu
How-To Beginner 2 min read 348 words

Cron Expression Syntax Guide

Write and debug cron schedule expressions for task automation, with examples for common scheduling patterns.

Cron Expression Syntax

Cron expressions define recurring schedules using five fields: minute, hour, day of month, month, and day of week. Mastering this syntax lets you schedule tasks with precision.

The Five Fields

┌───── minute (0-59)
│ ┌───── hour (0-23)
│ │ ┌───── day of month (1-31)
│ │ │ ┌───── month (1-12)
│ │ │ │ ┌───── day of week (0-7, both 0 and 7 = Sunday)
* * * * *

An asterisk means "every value." A specific number means "only at that value." Ranges (1-5), lists (1,3,5), and step values (*/5 = every 5th) provide additional precision.

Common Patterns

0 9 * * 1-5 — 9:00 AM every weekday. */15 * * * * — every 15 minutes. 0 0 1 * * — midnight on the first of every month. 30 2 * * 0 — 2:30 AM every Sunday. 0 */6 * * * — every 6 hours (midnight, 6am, noon, 6pm).

Timezone Considerations

Cron traditionally runs in the server's timezone. If your server is in UTC and you want a job at 9 AM Eastern, you need to account for the offset — and the offset changes with daylight saving time (UTC-5 in winter, UTC-4 in summer). Modern cron implementations support CRON_TZ or the TZ directive to specify the intended timezone.

Testing Expressions

Browser-based cron expression tools show the next N execution times for any expression. Enter your cron expression and verify that the scheduled times match your intent. Pay special attention to edge cases: the 31st of months that have 30 days, February 29th, and timezone transitions.

Common Mistakes

0 0 * * 7 runs on Sunday (both 0 and 7 mean Sunday in most implementations). 0 0 31 * * only fires in months with 31 days. */10 9-17 * * * fires every 10 minutes during business hours, but includes 17:00, 17:10, etc. if you meant "until 5 PM", use 9-16. Step values start from 0: */3 in the hour field means 0, 3, 6, 9... not 1, 4, 7, 10.

관련 도구

관련 포맷

관련 가이드