Cron Syntax: Orchestrating the Clock
Published: April 5, 2026 | Category: Programming & Standards
In the Unix world, cron is a time-based job scheduler. It allows developers to run scripts and commands at specific times, dates, or intervals. Whether it's a daily database backup or a weekly newsletter, cron is the engine that keeps things running automatically.
The Anatomy of a Cron String
A standard cron string consists of five (or sometimes six) fields separated by spaces.
* * * * * command
- Minute: 0 - 59
- Hour: 0 - 23
- Day of Month: 1 - 31
- Month: 1 - 12 (or names like JAN)
- Day of Week: 0 - 6 (Sunday to Saturday, or names like SUN)
Special Symbols
- * (Asterisk): Means "every." For example, a `*` in the minute field means "every minute."
- , (Comma): Allows you to specify a list. `1,15,30` in the minute field means "at minutes 1, 15, and 30."
- - (Hyphen): Specifies a range. `1-5` in the day-of-week field means "Monday through Friday."
- / (Slash): Specifies increments. `*/15` in the minute field means "every 15 minutes."
Common Scheduling Examples
| Cron Expression | Description |
|---|---|
| 0 0 * * * | Executes daily at midnight. |
| 0 12 * * 1 | Executes every Monday at noon. |
| */5 * * * * | Executes every 5 minutes. |
| 30 2 1 * * | Executes at 2:30 AM on the first day of the month. |
@Macros: The Shorthand
Many modern systems (like Linux's Vixie cron) support shortcuts that replace the entire five-field string:
- @yearly: Once a year at midnight on Jan 1st.
- @monthly: Once a month at midnight on the 1st.
- @weekly: Once a week at midnight on Sunday.
- @daily: Once a day at midnight.
- @reboot: Once at startup.
Conclusion
Cron syntax is the universal language of automation. It has remained largely unchanged for decades because its logic is both powerful and compact. On the Epoch Clock, you see the current second. Using a cron job, you could decide exactly what the computer should do at that precise second.