English

Developer tools · Crontab generator

How the five crontab fields work: minute, hour, day, month, weekday

· How it works

cron scheduling developer-workflow

Five positions of a cron schedule aligned with clock and calendar symbols
Original ToolAcre vector illustration

Every cron schedule is five positional fields, and the order never changes. This post explains each field's range, the special case of Sunday, and how a line becomes a set of matching minutes.

A backup that must run at 02:30 every night — and five stars you are not sure how to fill

You need a backup at 02:30 nightly but keep mixing up which of the five stars owns the hour. Cron is positional: a number in the wrong column produces a different schedule while looking superficially valid. Start with the time the job must run, the machine’s timezone and who owns the crontab; only then fill fields. ToolAcre can parse and describe an expression, but it does not install the job or run your backup command.

Positional fields, fixed order — minute, hour, day of month, month, day of week, then the command

A user crontab line has minute, hour, day of month, month, day of week, then a command. In 30 2 * * * backup.sh, 30 is the minute and 2 is the hour: 02:30 each day under that cron environment’s time zone. The command is not a sixth time field. System-wide /etc/crontab may include a user field before the command, which is why blindly copying a system entry into your personal crontab can run an unintended command.

Ranges of each field — 0–59, 0–23, 1–31, 1–12 and 0–7, with 0 and 7 both meaning Sunday in most crons

Minutes accept 0–59, hours 0–23, day of month 1–31, month 1–12 and weekday 0–7 in the Vixie-style conventions ToolAcre models; 0 and 7 mean Sunday. An asterisk means all values in that field. Ranges and comma-separated lists can restrict values, but a field’s numeric range still applies. 25 in the hour position is not a late-night schedule: it is invalid and should be reported rather than wrapped to the next day.

How matching works — cron wakes each minute and runs a line if the time fields match (with one exception for the two day fields)

Cron checks matching fields at each minute. Minute, hour and month all need to match. The two day fields have a special rule in Vixie cron: when both day-of-month and day-of-week are restricted, a match on either can trigger the job, not necessarily both. Thus 0 0 13 * 5 means the thirteenth of a month or each Friday, not only Friday the thirteenth. With wildcards in the day positions, the nightly example behaves as intended. The tool’s explanatory output makes that choice visible before installation.

Worked example: 30 2 * * * backup.sh — reading it aloud, then writing 'weekdays at 08:15' from scratch

Read 30 2 * * * backup.sh aloud as “run backup.sh at 02:30 every day.” For weekdays at 08:15, put minute 15, hour 8, unrestricted day/month and weekdays 1–5: 15 8 * * 1-5. Paste only the five schedule fields into the Crontab generator and check its description and next-run list; install the command using your own crontab editor afterward. For a backup that runs near a daylight-saving change, verify the next-run timestamps in the actual zone rather than assuming every local 02:30 exists.

Names for months and weekdays, including supported name ranges

Many cron dialects accept three-letter names such as JAN or MON instead of numbers. Names can make a human-maintained schedule clearer, but using 0/7 for Sunday remains common and other cron implementations may have different extensions. ToolAcre recognises common month and weekday names and ranges such as JAN-MAR and MON-FRI; its parser accepts 15 8 * JAN-MAR MON-FRI. Another cron implementation or cloud scheduler may use a different number of fields or extension, so consult that environment’s own grammar before installing the line.

What this overview does not fully cover: lists, steps and the execution environment

This introduction explains the Vixie day-field OR rule but does not explore its complicated combinations with lists and steps, the shell/environment that executes the command or daylight-saving behavior; each can change whether a real task runs. The validator can describe a schedule but cannot guarantee that backup.sh exists, has permission or wrote recoverable backups. Test a backup and a restore before relying on a production cron entry.

Takeaway: five fields, one grammar — and the Crontab generator builds the expression and explains it back to you

Five positions form one grammar. Crontab generator reads your proposed schedule, names each field and shows upcoming executions in a chosen zone without installing anything on your system. Enter the nightly and weekday examples, compare what the tool says with what you intended, then keep the command and timezone decision with the job’s operational documentation.