ToolActToolAct

Cron Expression Generator

Visual generator and parser for Cron schedule expressions

Cron 表达式
* * * ? * *
每秒钟执行
常用
字段设置
秒 (0-59)
分 (0-59)
时 (0-23)
日 (1-31)
月 (1-12)
周 (0-6)
最近 5 次执行时间
12026-07-04 00:00:00
22026-07-04 00:01:00
32026-07-04 00:02:00
42026-07-04 00:03:00
52026-07-04 00:04:00

What is a Cron Expression?

A Cron expression describes recurring execution times for scheduled jobs. Depending on the scheduler, it may contain five, six, or seven fields for minute, hour, day of month, month, day of week, optional seconds, and optional year. Symbols such as asterisks, commas, ranges, steps, question marks, and special placeholders make rules like “every 5 minutes,” “weekdays at 9,” or “the last day of the month” possible. This tool helps read, validate, and preview upcoming run times so schedules are not guessed from memory. Context matters: Linux cron, Quartz, cloud schedulers, and application frameworks differ in field count, timezone handling, and supported syntax.

How to Use

How to use

  1. Select generate or parse mode
  2. Set time fields (second, minute, hour, day, month, weekday) via dropdowns
  3. Click presets to quickly fill common expressions
  4. Generate mode shows the expression and next 5 run times
  5. Parse mode validates existing expressions and shows run times

Syntax Symbols

  • * — All possible values
  • , — List multiple values (e.g., 1,3,5)
  • - — Range (e.g., 1-5)
  • / — Step interval (e.g., */5 means every 5)
  • ? — No specific value (for day or weekday)
  • L — Last day of month/week
  • W — Nearest weekday
  • # — Nth weekday (e.g., 2#3 = 3rd Tuesday)

Development notes

  • Use the result as a quick reference, then test it in the real code, build, or API context.
  • Consider versions, dialects, environment variables, and project conventions.

Important Notes

  • Day and weekday fields cannot both have values; one must use ?
  • Each field has valid ranges: minute 0-59, hour 0-23
  • Field order is fixed: sec min hour day month weekday year
  • Weekday is case-insensitive; MON and mon are equivalent

Use Cases

Build Quartz-style schedules without memorizing every fieldUse the visual field controls to assemble a 6-field expression with seconds, minutes, hours, day, month, and weekday, including ranges, steps, last day, workday, and nth-weekday patterns. The expression builder is purely client-side, so a draft schedule can be checked against a project config file or a scheduled-job JSON before it is committed and pushed.
Parse an existing cron expression before deploying itPaste a 5-field or 6-field expression to populate the controls and catch whether a schedule is using seconds, day-of-month, weekday, or ? in the way you expect. The parsed result shows a plain-language description and the next several run times, which is the fastest way to catch a schedule that fires at midnight when the job was meant to run during business hours.
Review the next run times for sanityCheck the generated human description and next five run times before using the expression for jobs, reports, backups, reminders, or server tasks that are painful to reschedule after deployment. This catches off-by-one weekday choices and unexpected second-field behavior early. A schedule pinned to 0 0 0 29 2 ? for February 29 will silently skip every common year, so the parsed preview makes that gap visible before the job is wired into a payroll or batch-closing flow.
Mind the difference between Linux cron and Quartz syntaxA 5-field expression runs on Linux cron and Unix daemons; a 6-field expression with seconds runs on Quartz, Spring, and most cloud schedulers. Confirm the target system before saving, because the same digits mean different schedules. Quartz also accepts shorthand like @hourly, @daily, @midnight, @weekly, @monthly, @yearly, and @reboot, which collapse to fixed five- or six-field expressions and are convenient in Spring's @Scheduled annotation but rejected by classic crond.
Check timezone handling before job deploymentInspect whether the scheduler interprets the cron expression in server time, UTC, or a named zone like America/New_York, since a job written in headquarter time can fire several hours late on a globally deployed worker.

Technical Principle

A cron expression encodes zero or more time-matching constraints across fields in a fixed order. The classic Vixie/BSD cron (used by Linux crond) uses 5 fields: minute (0-59), hour (0-23), day-of-month (1-31), month (1-12 or JAN-DEC), and day-of-week (0-6 or SUN-SAT, with Sunday = 0 by convention). The Quartz scheduler, popularized by Spring and the Egistix library, adds a leading seconds field for 6 fields and an optional trailing year field for 7. Each field can take a literal value, a list (1,3,5), a range (1-5), a step (0/15 meaning every 15 starting at 0), or the wildcard * which matches all values. The question mark ? is a Quartz-only sentinel meaning "no specific value" and MUST appear in exactly one of the day-of-month or day-of-week positions when the other has a constraint. Computing the next N execution times uses a greedy forward-search algorithm: start from the reference instant (usually now), increment the lowest-level field that does not match the constraint, reset all lower fields to their minimum, and cascade to higher fields when a field rolls over (e.g. minutes rolling past 59, hours past 23). This is known as the Donovan/Spoonhour iterative method and runs in O(K x F) where K is the number of candidates (usually 5) and F is the field count. Weekday names (MON, FRI, etc.) are folded to lowercase and matched, and month-name abbreviations are also accepted. The L special character in Quartz resolves to the last occurrence of a weekday in the month (e.g. 0 0 0 ? * 5L is the last Friday), calculated by counting down from the month's last day to find the requested weekday. The W character finds the nearest weekday (Mon-Fri) to a given day-of-month, skipping into the adjacent month if needed. Timezone handling is the most common misconfiguration: the expression itself carries no timezone metadata, so the same 0 0 9 * * ? fires at different UTC offsets on servers in America/New_York vs. Asia/Tokyo vs. UTC. Shorthands like @daily (0 0 0 * * ?), @hourly (0 0 * * * ?), @reboot (run once at daemon start, not a time expression), and @weekly (0 0 0 ? * 1) are expanded to their equivalent 6-field form before parsing. A common pitfall is the day-of-month + day-of-week conjunction: in classic cron the job runs when either matches (OR logic), while some newer dialects switch to AND logic. The expression 0 0 0 15 * 5 means "at midnight on the 15th AND on every Friday" in Vixie cron, not "at midnight on the 15th OR on Friday" as many beginners assume. The Y2038 problem does not affect cron directly (it uses time_t), but any embedded device running a 32-bit Unix crond will overflow the time_t signed 32-bit integer on 2038-01-19T03:14:07Z.

  • Classic 5-field: min hour dom mon dow; Quartz adds sec (6-field) and optionally year (7-field).
  • ? must occupy one of dom/dow when the other has a value; * matches all values in that field.
  • Day-of-month + day-of-week is OR in Vixie cron, AND in some newer schedulers - verify before deploying.
  • L resolves to last weekday of month: e.g. 0 0 0 ? * 5L = last Friday, computed from the month length.
  • W finds the nearest business day (Mon-Fri) to a given date; may cross into the adjacent month.
  • Cron expression carries no timezone metadata: the same expression fires at server-local time, UTC, or a named zone depending on the scheduler.
  • Y2038: 32-bit time_t overflows on 2038-01-19 03:14:07 UTC; crond on legacy embedded systems will be affected.
  • Shorthands @hourly/@daily/@midnight/@weekly/@monthly/@yearly/@reboot expand to equivalent 5-field or 6-field expressions.
  • The step / operator counts from the leftmost value: 2/3 on hour fires at 2, 5, 8, 11, 14, 17, 20, 23.
  • Five-iteration greedy forward-search in O(KxF) to compute next N run times from a reference instant.

Examples

Every day at midnight (daily backup)

Expression : 0 0 * * *
Means      : At 00:00 every day
Next runs  : 2026-06-11 00:00, 2026-06-12 00:00, 2026-06-13 00:00
Use case   : Database backup, daily report generation

Every 15 minutes (health check)

Expression : */15 * * * *
Means      : At minute 0, 15, 30, 45 of every hour
Next runs  : 14:00, 14:15, 14:30, 14:45, 15:00
Use case   : API health check, queue polling, sync jobs

Weekdays at 9:00 AM (work-hours notifier)

Expression : 0 9 * * 1-5
Means      : 09:00 from Monday to Friday
Next runs  : Mon 09:00, Tue 09:00, Wed 09:00, Thu 09:00, Fri 09:00
Use case   : Stand-up reminder, Slack daily digest

First day of every month at 03:30 (monthly billing)

Expression : 30 3 1 * *
Means      : 03:30 on the 1st of every month
Next runs  : Jul 1 03:30, Aug 1 03:30, Sep 1 03:30
Use case   : Monthly invoice run, log rotation, archive

Every Sunday at midnight (weekly cleanup)

Expression : 0 0 * * 0
Means      : 00:00 every Sunday (0 = Sunday in Linux cron)
Next runs  : Sun 00:00, Sun 00:00, Sun 00:00
Use case   : Weekly report email, cache purge, retraining

Quartz with seconds - every 30 seconds

Expression : */30 * * * * ?
Means      : Every 30 seconds (6-field Quartz syntax)
Next runs  : 14:00:00, 14:00:30, 14:01:00, 14:01:30
Note       : Day-of-week is ?, because day-of-month is *. Use Quartz, not Linux cron, for this format.

FAQ

Which cron formats are supported?

Standard 5-field cron (minute hour dayOfMonth month dayOfWeek), 6-field with seconds (used by Quartz, Spring, and many cloud schedulers), and 7-field with optional year. The page lets you pick the format and explains each field as you build the expression.

Why are dayOfMonth and dayOfWeek both fields?

Standard cron treats them as OR: 'first day of month OR every Monday' fires on either condition. To AND them, you typically need a non-standard ?-syntax (Quartz) or a workaround. The page shows the next fire times so you can verify your intent visually.

Will the schedule actually run on my system?

No - this page generates and validates the expression, but the job runs in your scheduler (Linux cron, GitHub Actions, Kubernetes CronJob, AWS EventBridge, Quartz, etc). Different schedulers have slightly different cron dialects; pick the right format for your target.

What time zone does the schedule use?

Standard Unix cron uses the system local time zone. Cloud schedulers vary - AWS EventBridge defaults to UTC, GitHub Actions defaults to UTC, Kubernetes CronJob uses the API server's timezone. Read your scheduler's docs and remember that DST transitions can fire jobs at unexpected times.

How can I express 'every 30 minutes'?

*/30 * * * * (minute = 0,30; every hour, day, month, day of week). For 'every 15 minutes only during business hours': */15 9-17 * * 1-5 (also restricts to 9-17:00 Mon-Fri). The page shows the next 5-10 fire times to confirm.

Is this safe to use for real production schedules?

The page only generates the expression; running the job is your scheduler's job. Test the expression with a sample run first (most schedulers have a 'manual run' option), and avoid scheduling jobs at midnight (00:00) where many systems' jobs collide and cause spikes.

Is anything uploaded?

No. The expression is parsed and the next fire times are computed in your browser using a JavaScript cron library.