> codebench_TOOL: HomeLOCAL-ONLY⌘K Switch

Cron Expressions: What Five and Six Fields Mean Across Schedulers

Read cron expressions from left to right, try common schedules, and learn why an extra field means different things in different schedulers.

·3 min readAbout the maintainer

*/15 * * * * runs on the quarter hours. Add a 30 at the front and CodeBench reads it as 30 seconds past each quarter hour. GitHub Actions, on the other hand, expects five fields. Before copying a cron expression, check which scheduler will read it.

The five fields

In a classic crontab, the schedule has five fields in this order. The command that follows in a crontab entry is not part of the schedule expression.

minute  hour  day-of-month  month  day-of-week
 0–59   0–23      1–31      1–12    0–6 (Sun–Sat)

Read each field as a set of allowed values. * means every value, 1-5 is an inclusive range, and 1,3,5 is a list. A step such as */15 in the minute field picks 0,15,30,45. It does not start a 15-minute timer when you save the job. Steps reset within their field: */35 in the minute field runs at :00 and :35, then at :00 again just 25 minutes later.

Expression When it runs
*/15 * * * * At minutes 0, 15, 30, and 45 of every hour
30 8 * * 1-5 At 08:30 Monday through Friday
0 0 1 * * At midnight on the first day of each month

Take particular care with the two day fields. In traditional cron, when both are restricted, either one can match. 0 9 1 * 1 means 09:00 on the first of the month or on a Monday, not just when the first falls on Monday. CodeBench's Cron Parser lists runs on either day even though its English description says “and.” Cron Builder's separate preview requires both fields to match, so don't use it to verify this case. If you need only the first Monday, schedule Mondays and have the job check whether the day of the month is 1 through 7.

Where the sixth field goes

CodeBench uses a seconds-first dialect for six fields:

second  minute  hour  day-of-month  month  day-of-week
  30     */15     *        *          *         *

That runs at 08:00:30, 08:15:30, 08:30:30, and so on. With five fields, CodeBench's parser uses second zero. Quartz also puts seconds first, but it has its own rules for the day fields (? denotes no specific value) and can take an optional year at the end. The field count alone does not make an expression portable.

For GitHub Actions on.schedule, stick to five fields and a minimum interval of five minutes. The example below uses the default time zone, UTC. It schedules a run for 08:30 UTC on weekdays, not 08:30 in your browser. Scheduled workflows can be delayed, so don't treat the expression as a guarantee of an exact start time.

on:
  schedule:
    - cron: '30 8 * * 1-5'

Check the next runs, not just the description

  1. Open Cron Builder and select Weekdays 9am from the presets. It builds the five-field expression 0 9 * * 1-5. The next-run list skips Saturday and Sunday.
  2. Paste */15 * * * * into Cron Parser, then try 30 */15 * * * *. The field breakdown gains a seconds field, and the next runs move from :00 to :30 in the seconds position.
  3. Check the time zone separately. CodeBench previews runs in the browser's local zone. Your scheduler may use another zone. If the job must run at a particular local hour, check how the target handles skipped or repeated times at daylight saving transitions.

Summary

  • Five fields start with minutes. CodeBench's six-field format starts with seconds.
  • Steps match clock values, not elapsed time since the last run.
  • Check the real scheduler's dialect and time zone before installing a schedule.

See the POSIX crontab specification for the basic field order and day matching, and the Quartz CronTrigger tutorial for the Quartz dialect.

#cron#scheduling#automation#github-actions
> codebench $Ctrl+Enter Run