$devtoolkit.sh/glossary/what-is-cron

What is Cron? — Cron Syntax and Scheduling Explained

Definition

Cron is a time-based job scheduler in Unix-like operating systems that runs commands or scripts automatically at specified times. Scheduled tasks are called cron jobs and are defined in a configuration file called a crontab (cron table). Cron expressions are widely adopted beyond Unix — GitHub Actions, Kubernetes CronJobs, AWS EventBridge, and many cloud platforms use cron syntax for scheduling.

How It Works

A cron expression has five fields separated by spaces: minute (0–59), hour (0–23), day of month (1–31), month (1–12), and day of week (0–7, where 0 and 7 are Sunday). Each field accepts a specific value, a range (1-5), a list (1,3,5), a step value (*/15 for every 15 units), or * for "any". The cron daemon checks every minute whether any scheduled job's expression matches the current time, and if so, executes it. Environment variables and working directory must be set explicitly in crontabs because cron runs with a minimal environment.

Common Use Cases

  • Running database backups at 2 AM daily
  • Sending weekly email digests or reports every Monday at 9 AM
  • Polling an external API for new data every 5 minutes
  • Clearing cache or expired sessions hourly
  • Running CI/CD pipelines on a schedule in GitHub Actions

Example

# ┌ minute (0-59)
# │ ┌ hour (0-23)
# │ │ ┌ day of month (1-31)
# │ │ │ ┌ month (1-12)
# │ │ │ │ ┌ day of week (0-7, Sun=0)
# │ │ │ │ │
  0 2 * * *     # daily at 2 AM
  */5 * * * *   # every 5 minutes
  0 9 * * MON   # every Monday at 9 AM
  0 0 1 * *     # first day of each month

Related Tools

FAQ

Why does my cron job not run when expected?
Common causes: cron uses the server timezone, not UTC (check with crontab -e TZ=UTC). The PATH in cron is minimal — use absolute paths to commands. Output and errors go to the user's mail, not the terminal. Add 2>&1 and redirect to a log file to see errors.
What does */5 mean in a cron expression?
*/5 in the minute field means "every 5 minutes" (0, 5, 10, 15, ...). The / operator defines steps. In the hour field, */6 would mean at hours 0, 6, 12, 18 — every 6 hours.
What is the difference between cron and a crontab?
Cron is the daemon process (crond) that runs scheduled tasks. A crontab is a file that lists scheduled tasks for a specific user, edited with the crontab -e command. System-wide cron jobs are in /etc/cron.d/ or /etc/crontab.

Related Terms

/glossary/what-is-cronv1.0.0