DevOps & Automation

Crontab Syntax Demystified: Common Schedules, Timezones & Automation Traps

The cron daemon is the backbone of automated task scheduling in UNIX and Linux systems. Yet even seasoned engineers stumble over its 5-field syntax, stripped environment variables, and silent failure modes.

Saud Siraj• Published Sep 2026• 6 min read

Need to generate a cron expression visually?

Use our Crontab Expression Generator to build and translate cron syntax into plain English instantly.

Open Cron Generator

1. The Classic 5-Field Cron Expression

Standard UNIX cron schedule expressions consist of exactly five fields separated by white space:

* * * * * <command to execute>
│ │ │ │ │
│ │ │ │ └────── Day of week (0 - 7) (0 or 7 is Sunday)
│ │ │ └────────── Month (1 - 12)
│ │ └──────────── Day of month (1 - 31)
│ └────────────── Hour (0 - 23)
└──────────────── Minute (0 - 59)

2. Special Operators & Modifiers

You can combine four primary operators inside any cron field to define intricate recurrence rules:

  • Asterisk (*): Wildcard meaning "every possible value" for this field.
  • Comma (,): Value list (e.g. 1,15,30 in the minute field runs at minutes 1, 15, and 30).
  • Hyphen (-): Range of values (e.g. 1-5 in day-of-week runs Monday through Friday).
  • Slash (/): Step values (e.g. */15 in minute runs every 15 minutes: 0, 15, 30, 45).

3. Cheatsheet of Common Production Cron Schedules

ScheduleCron ExpressionHuman Meaning
Every 5 minutes*/5 * * * *Queue worker healthcheck or cache warm
Every hour at minute 00 * * * *Hourly metrics aggregation
Every night at 2:30 AM30 2 * * *Daily database backup snapshot
Every Monday at 9:00 AM0 9 * * 1Weekly billing and email digest
First of every month at midnight0 0 1 * *Monthly customer invoicing cycle

4. The #1 Automation Trap: Stripped Environment Variables

The single most common bug when deploying cron scripts: "My script runs when I type it in bash, but fails when executed by cron!"

When the cron daemon runs a task, it does not load your interactive shell profile (such as .bashrc or .zshrc). Its $PATH variable is severely stripped down (often to only /usr/bin:/bin).

Therefore, commands like node, python3, or docker cannot be found unless you supply the absolute path:

# ❌ Fails: cron doesn't know where python3 or backup.py is located
0 2 * * * python3 backup.py

# ✅ Works: Always specify absolute binary and file paths
0 2 * * * /usr/bin/python3 /var/www/scripts/backup.py

5. Output Redirection & Logging

By default, cron attempts to send output through local mail (sendmail / postfix), which is rarely configured on modern cloud servers. If your task errors, the error output is lost silently.

Always redirect both standard output (stdout) and standard error (stderr) to a log file:

# Redirect stdout (1) and stderr (2) to the same logfile
0 2 * * * /usr/bin/node /app/clean.js >> /var/log/clean.log 2>&1