Cron Expression Format
I. Basic Structure of Cron Expressions (with Authoritative Sources)
A standard cron expression consists of 5 time fields and 1 command field, following Unix and Linux system conventions. According to IEEE Std 1003.1-2017 (POSIX Standard)[1] and Linux man 5 crontab
documentation[2], the format is:
* * * * * command-to-execute
│ │ │ │ │
│ │ │ │ └── Day of Week (0-7, both 0 and 7 represent Sunday)
│ │ │ └──── Month (1-12)
│ │ └────── Day of Month (1-31)
│ └──────── Hour (0-23)
└────────── Minute (0-59)
Authoritative Notes:
- The POSIX Standard[1] defines the minimum compatibility specification, requiring support for
*
, ,
, and -
symbols.
- Linux system
cron
implementations (like Cronie) extend functionality with step values (/
) and special strings (@daily
, etc.), as detailed in their official documentation[3].
II. Time Field Symbol Rules
Each time field supports the following special symbols:
Symbol |
Description |
Example |
* |
Matches any value |
* in minutes = every minute |
, |
Specifies multiple values |
1,3,5 = minutes 1, 3, and 5 |
- |
Defines a range |
10-15 = minutes 10 through 15 |
/ |
Step values (interval) |
*/5 in minutes = every 5 minutes |
? |
"No specific value" (only for DOM/DOW) |
Used to avoid conflicts |
Modern cron implementations (like Vixie cron and its derivatives) support richer syntax rules. According to IBM Cron Reference Documentation[4] and Cronie Project Wiki[3], the following symbols are widely supported:
Symbol |
Description |
Official Documentation Example |
L |
Last day (supported by some implementations) |
0 0 L * * = Execute on the last day of each month[5] |
W |
Nearest weekday (e.g., 15W = closest weekday to the 15th) |
See Quartz Scheduler Documentation[6] (common in Java ecosystem) |
III. Origin of Predefined Aliases (@daily, etc.)
@daily
, @weekly
, and similar aliases originate from Paul Vixie's cron implementation (Vixie cron, released in 1987)[7], and are now default features in modern Linux distributions (like Debian, Red Hat). According to the Debian cron
Manual[8]:
# Equivalent to 0 0 * * *
@daily /path/to/script
IV. Common Implementation Differences and Considerations
Different cron implementations have subtle variations, requiring reference to their respective documentation:
Implementation |
Features |
Official Resource Link |
Cronie |
Red Hat's default cron, supports @ shortcuts |
Cronie GitHub |
systemd |
Replaces cron with .timer units (recommended for new systems) |
systemd.timer Manual |
fcron |
Supports more complex syntax (e.g., @yearly ) |
fcron Website |
V. Recommended Validation Tools and Authoritative References
-
Crontab Manual Page
Run man 5 crontab
in terminal for complete syntax - the most direct local authoritative reference.
-
Cron Expression Generators
-
Open Source Project Documentation
VI. Summary
By combining POSIX standards, Linux manual pages, and major implementations (like Cronie) documentation, users can precisely understand cron expression core logic. For advanced usage (like L
and W
), note implementation compatibility and prioritize official resources.
References