Skip to content
utility2026-07-253 min read

What Is a Cron Expression

A Cron expression is a string format for configuring scheduled task execution, widely used in Linux crontab, CI/CD pipelines, Node.js task schedulers, and distributed job systems.

A standard Cron expression consists of 5 time fields:

┌───────────── Minute (0-59)
│ ┌───────────── Hour (0-23)
│ │ ┌───────────── Day of Month (1-31)
│ │ │ ┌───────────── Month (1-12)
│ │ │ │ ┌───────────── Day of Week (0-7, 0 and 7 = Sunday)
│ │ │ │ │
* * * * *

Why You Need a Cron Expression Parser

  1. Scheduled tasks: Server backups, data sync, report generation
  2. CI/CD scheduling: Timed builds and deployments
  3. Monitoring: Periodic health checks
  4. Data processing: ETL jobs, log rotation
  5. Understanding complex expressions: Visualize next execution times

Cron Field Syntax

Special Characters

| Character | Meaning | Example | |-----------|---------|---------| | * | Any value | * * * * * = every minute | | , | List | 1,3,5 * * * * = minutes 1, 3, 5 | | - | Range | 1-5 * * * * = minutes 1 through 5 | | / | Step | */15 * * * * = every 15 minutes |

Common Cron Expressions

| Expression | Meaning | |------------|---------| | * * * * * | Every minute | | 0 * * * * | Every hour on the hour | | 0 0 * * * | Daily at midnight | | 0 9 * * 1-5 | Weekdays at 9:00 AM | | 0 0 1 * * | First of every month at midnight | | 0 0 * * 0 | Every Sunday at midnight | | */5 * * * * | Every 5 minutes | | 0 */2 * * * | Every 2 hours | | 30 8 * * 1 | Monday at 8:30 AM | | 0 0 1,15 * * | 1st and 15th of every month |

How to Use an Online Cron Parser

Using DevToolkit Pro's Cron Expression Parser:

  1. Enter a Cron expression (e.g., */15 * * * *)
  2. The tool parses each field's meaning
  3. Shows a human-readable description (e.g., "Every 15 minutes")
  4. Lists the next 5-10 execution times
  5. Syntax error detection included

Cron in Code

Node.js

const cron = require('node-cron');

// Every 5 minutes
cron.schedule('*/5 * * * *', () => {
  console.log('Running health check');
});

// Daily at 2:00 AM
cron.schedule('0 2 * * *', () => {
  console.log('Running data backup');
});

Python

from crontab import CronTab

# Parse a Cron expression
cron = CronTab('* * * * *')
print(cron.description())  # "Every minute"

# Get next execution time
from datetime import datetime
next_run = cron.get_next(datetime)

Go

import "github.com/robfig/cron/v3"

c := cron.New()
// Every 5 minutes
c.AddFunc("*/5 * * * *", func() {
    fmt.Println("Running health check")
})
c.Start()

Important Notes

Timezone

Cron expressions default to the server's local timezone. In distributed systems, use UTC consistently:

# UTC time
0 2 * * *    # Daily at UTC 02:00

Sunday Representation

Different systems represent Sunday differently:

  • 0 = Sunday (most systems)
  • 7 = Sunday (some systems)
  • 1 = Monday

Minimum Granularity

Standard Cron's minimum granularity is minutes. For second-level scheduling, use extended Cron syntax (e.g., */5 * * * * * — 6 fields).

FAQ

What's the Relationship Between Cron Expressions and crontab?

A Cron expression is the string representation of a scheduling rule. crontab is the file/command in Linux for configuring scheduled tasks. You write Cron expressions into crontab to configure jobs.

Are */15 * * * * and 0,15,30,45 * * * * the Same?

They produce the same result — both execute every 15 minutes. */15 is shorthand step syntax.

How Do I Schedule Monday Through Friday?

Use * * * * 1-5. In the day-of-week field, 1=Monday, 5=Friday, 0 or 7=Sunday.


This article is brought to you by DevToolkit Pro. More developer tools at the homepage.


ad