In Unix-like systems, server automation, cloud functions (AWS Lambda, Google Cloud Tasks), and backend web frameworks, cron expressions are the international standard for defining scheduled repetitive tasks. Whether triggering automated database backups at midnight, dispatching email digests every Monday morning, or pruning temporary cache logs hourly, mastering cron syntax is fundamental for every developer and systems administrator.

1. What is a Cron Job & Expression?

Originating from the Greek word chronos (time), cron is a background daemon that executes commands at scheduled intervals. A cron expression is a string of space-separated fields that mathematically defines the exact execution schedule.

2. The Standard 5-Field Unix Crontab Architecture

The standard Unix crontab specification consists of exactly 5 fields in strict order:

┌───────────── Minute (0 - 59)
│ ┌───────────── Hour (0 - 23)
│ │ ┌───────────── Day of the Month (1 - 31)
│ │ │ ┌───────────── Month (1 - 12 or JAN-DEC)
│ │ │ │ ┌───────────── Day of the Week (0 - 7 or SUN-SAT, 0 & 7 = Sunday)
│ │ │ │ │
* * * * *
Field Position Field Name Allowed Values Special Characters
1 Minute 0 - 59 * , - /
2 Hour 0 - 23 (24-Hour Format) * , - /
3 Day of Month 1 - 31 * , - / ? L W
4 Month 1 - 12 (or JAN - DEC) * , - /
5 Day of Week 0 - 6 (0 = Sunday; or SUN - SAT) * , - / ? L #

3. Special Operators & Wildcards (*, /, -, ,)

  • Asterisk (*): Matches all possible values in that field. In the minute field, * means "every single minute".
  • Comma (,): Defines a discrete list of values. For example, 15,45 * * * * executes at minute 15 and minute 45 of every hour.
  • Hyphen (-): Defines an inclusive range. For example, 0 9-17 * * * runs every hour from 9:00 AM to 5:00 PM.
  • Slash (/): Defines step intervals. For example, */15 * * * * runs every 15 minutes (0, 15, 30, 45).

4. Essential Production Crontab Recipes

Schedule Description Cron Expression Typical Enterprise Use Case
Every 5 minutes */5 * * * * Queue worker polling & health checks
Every hour at the top of the hour 0 * * * * Log rotation & temporary cache purging
Every night at midnight (00:00 UTC) 0 0 * * * Daily database backup & reporting rollup
Every Monday morning at 8:30 AM 30 8 * * 1 Weekly analytics report email dispatch
First day of every month at 02:00 0 2 1 * * Monthly subscription billing & invoicing

5. Critical Timezone & Daylight Saving Traps

By default, server cron daemons evaluate schedules against the operating system's local system time. In distributed cloud systems, always configure your server clock to UTC (Coordinated Universal Time) to prevent tasks from executing twice (or being skipped entirely) during Daylight Saving Time (DST) clock shifts.