Cron Expression Syntax Explained for Developers

What Is a Cron Expression?

A cron expression is a string of five (or six) fields separated by spaces that defines a schedule for automated tasks. Originally designed for the Unix cron daemon, this syntax is now used by cloud platforms, CI/CD pipelines, task schedulers, and application frameworks worldwide.

The five standard fields are: minute (0-59) hour (0-23) day-of-month (1-31) month (1-12) day-of-week (0-7, where 0 and 7 are Sunday). Each field can contain a specific value, a range, a list, or special characters.

Special Characters

Asterisk (*): Matches every possible value. An asterisk in the minute field means every minute.

Comma (,): Separates multiple values. 1,15 in the day-of-month field means the 1st and 15th.

Hyphen (-): Defines a range. 1-5 in the day-of-week field means Monday through Friday.

Slash (/): Defines step values. */15 in the minute field means every 15 minutes (0, 15, 30, 45). 1/3 in the hour field means every 3 hours starting at hour 1 (1, 4, 7, 10, 13, 16, 19, 22).

Some implementations add a sixth field for seconds and support additional characters like L (last), W (weekday), and # (nth occurrence).

Common Scheduling Patterns

Here are frequently used cron expressions with explanations:

Reading Cron Expressions

Read each field from left to right: minute, hour, day-of-month, month, day-of-week. The expression 30 14 * * 1-5 reads as: at minute 30, of hour 14 (2 PM), on any day of the month, in any month, but only on days 1 through 5 (Monday through Friday). In plain language: every weekday at 2:30 PM.

When both day-of-month and day-of-week are specified (not asterisks), most cron implementations run the job when either condition is met, not when both are met. This is a common source of confusion. If you set day-of-month to 15 and day-of-week to 1, the job runs on every 15th and every Monday.

Platform-Specific Variations

Standard Unix cron: Five fields, no seconds. Supports basic characters.

AWS CloudWatch/EventBridge: Six fields (adds year), uses different day-of-week numbering (1 = Sunday through 7 = Saturday), and supports additional keywords like L, W, and #.

GitHub Actions: Uses standard five-field format but runs in UTC timezone.

Kubernetes CronJob: Standard five-field format. Timezone support was added in recent versions.

Spring Framework: Six fields with seconds, supports additional expressions.

Always check the documentation for your specific platform, as subtle differences in field ranges, special characters, and timezone handling can cause scheduling errors.

Use the cron expression tools on CalcHub to build and validate cron schedules, or explore our developer tools for other automation utilities.

Build and test cron expressions with CalcHub’s scheduling tools.

Explore all free tools on CalcHub

Browse Tools