fjordtools / Errors / crontab: bad minute

crontab: bad minute (errors in crontab file, can't install)

crontab checks every line of the file and names the first field it cannot accept, such as minute or hour, then refuses to install the whole file. A cron line has exactly five fields with fixed ranges. Check the value against its range, and count the fields.

Fjordtools team · Seen in Vixie-style cron on Linux and macOS · Published · 1 min read

Common causes

  1. A value is out of range

    Minutes run 0 to 59 and hours 0 to 23. Months run 1 to 12 and days of the month 1 to 31. Writing 60 for the minute, or 24 for the hour, is the classic slip.

    Input

    60 * * * *

    Cron Explainer says

    minute must be between 0 and 59
  2. The hour is out of range

    Midnight is hour 0, not 24.

    Input

    * 24 * * *

    Cron Explainer says

    hour must be between 0 and 23
  3. A step of zero

    A step divides the range, so */0 means nothing. To run every minute use * or */1.

    Input

    */0 * * * *

    Cron Explainer says

    Step "0" in minute must be a positive number
  4. Too few fields

    Standard cron wants minute, hour, day of month, month and day of week. A line with four fields has lost one.

    Input

    */5 * * *

    Cron Explainer says

    Expected 5 fields (minute hour day month weekday), found 4
  5. A seconds field

    Quartz, Spring and some cloud schedulers use six or seven fields with seconds first. System crontab does not.

    Input

    0 */5 * * * *

    Cron Explainer says

    This looks like a 6 or 7 field expression (seconds or year). Only the 5 standard fields are supported

How to fix it

  1. Read which field crontab names and compare the value with its range.
  2. Count the fields: minute, hour, day of month, month, day of week.
  3. For a seconds-level schedule use a scheduler that supports it; cron cannot run more often than once a minute.
  4. Paste the line into the cron explainer: it reads the schedule back in plain English.

Related tool

More error explainers are coming

See all errors.