ToolSphere
Back to all articles
cron

How Cron Expressions Work, Field by Field

2026-07-199 min read

Try it: free Cron Descriptor & Generator

Read a cron schedule in plain English

Open →

Introduction

In server administration, DevOps, and cloud scheduling, a cron job is a command line task scheduled to run automatically at specific intervals. The execution schedule is defined by a space-separated string of numbers and symbols called a cron expression.

While cron expressions are incredibly powerful, their syntax can be difficult for developers to parse at a glance. In this guide, we will break down standard cron formats, explain how wildcards work, and look at common configuration examples.


The 5-Field Standard Cron Format

Standard cron expressions contain 5 fields:
* * * * *
Each field corresponds to a distinct time metric (from left to right):

  1. Minute: 0 - 59
  2. Hour: 0 - 23 (24-hour format)
  3. Day of Month: 1 - 31
  4. Month: 1 - 12 (or JAN-DEC)
  5. Day of Week: 0 - 7 (where 0 or 7 is Sunday, or SUN-SAT)

Special Wildcards and Characters

To create complex recurrence rules, cron syntax supports special operators:

  • Asterisk (*): Matches any value. An asterisk in the hour field means "run every hour".
  • Comma (,): Defines a list of explicit values. E.g., 1,15,30 in the minutes field.
  • Hyphen (-): Specifies an inclusive range. E.g., 9-17 in the hours field means every hour from 9 AM to 5 PM.
  • Slash (/): Defines step increments. E.g., */15 in the minutes field means "every 15 minutes".

Common Cron Schedule Examples

  • 0 0 * * *: Runs once every day at midnight (12:00 AM).
  • */5 * * * *: Executes every 5 minutes.
  • 0 9 * * 1-5: Runs at 9:00 AM, Monday through Friday.
  • 30 18 1 * *: Executes at 6:30 PM on the 1st of every month.

Technical Implementation in TypeScript

Here is a compact describer for the five standard fields. It handles *, steps (*/5), ranges (1-5), lists (1,15,30) and stepped ranges (9-17/2), turns day and month numbers into names, and follows cron's rule that when both day fields are set the job runs on either. It shows names such as MON as written, and does not handle @daily-style shortcuts:

const DAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
const MONTHS = ['', 'January', 'February', 'March', 'April', 'May', 'June',
  'July', 'August', 'September', 'October', 'November', 'December'];

// One field: *, a step (*/5), a range (1-5), a list (1,15,30) or a stepped range (9-17/2).
function describeField(field: string, unit: string, names: string[] = []): string {
  if (field === '*') return `every ${unit}`;
  const step = field.match(/^\*\/(\d+)$/);
  if (step) return `every ${step[1]} ${unit}s`;
  const name = (v: string) => names[Number(v)] ?? v;
  return field.split(',').map((part) => {
    const [range, every] = part.split('/');
    const [from, to] = range.split('-');
    const span = to === undefined ? name(from) : `${name(from)} through ${name(to)}`;
    return every ? `every ${every} ${unit}s from ${span}` : span;
  }).join(', ');
}

export function describeCron(expression: string): string {
  const parts = expression.trim().split(/\s+/);
  if (parts.length !== 5) return 'Invalid: a cron expression has exactly 5 fields.';
  const [min, hour, dom, month, dow] = parts;
  const isNumber = (f: string) => /^\d+$/.test(f);

  let time: string;
  if (isNumber(min) && isNumber(hour)) time = `at ${hour.padStart(2, '0')}:${min.padStart(2, '0')}`;
  else if (hour === '*') time = min === '*' || min.startsWith('*/') ? describeField(min, 'minute') : `at minute ${min} of every hour`;
  else time = `at minute ${describeField(min, 'minute')} past ${describeField(hour, 'hour')}`;

  const monthDays = dom === '*' ? '' : dom.startsWith('*/') ? describeField(dom, 'day') : `on day ${describeField(dom, 'day')} of the month`;
  const weekDays = dow === '*' ? '' : `on ${describeField(dow, 'day', DAYS)}`;
  // When both day fields are restricted, cron runs on either one.
  const days = [monthDays, weekDays].filter(Boolean).join(' or ') || 'every day';
  const months = month === '*' ? '' : ` in ${describeField(month, 'month', MONTHS)}`;
  return `Runs ${time}, ${days}${months}.`;
}

Some outputs:

Expression Description
*/5 * * * * Runs every 5 minutes, every day.
0 9 * * 1-5 Runs at 09:00, on Monday through Friday.
0 0 1 * * Runs at 00:00, on day 1 of the month.
0 */2 * * * Runs at minute 0 past every 2 hours, every day.
0 9 1 * 1 Runs at 09:00, on day 1 of the month or on Monday.
15 10 * 1,7 * Runs at 10:15, every day in January, July.

Frequently Asked Questions

1. Does ToolSphere evaluate cron schedules on a server?

No. All translation and schedule checking execute locally in your browser sandbox.

2. Can I use the cron builder offline?

Yes. ToolSphere is fully client-side and functional offline.


Next Steps

To convert your cron strings into clear English sentences, check out the ToolSphere Cron Descriptor.

Use the Unix Epoch Timestamp Converter to inspect a timestamp when reviewing dates or schedules. For a related walkthrough, read How JSON Formatters Parse and Validate.

Looking for other tools?

Explore ToolSphere Homepage →