Cron

Cron is a Unix/Linux task scheduling system and its five-field syntax (minute, hour, day of month, month, day of week) for defining when to execute commands automatically.

Examples

  • 0 0 * * * — Every day at midnight
  • */15 * * * * — Every 15 minutes
  • 0 2 * * 0 — Sundays at 2 AM (weekly backups)
  • 30 9 * * 1-5 — 9:30 AM Monday to Friday
  • 0 */4 * * * — Every 4 hours

FAQ

What's the difference between cron and crontab?

Cron is the daemon (service) that executes scheduled tasks. Crontab is the command to edit a user's cron job table (crontab -e) or the file where those tasks are stored. Each user has their crontab, and there's a system crontab in /etc/crontab.

How do I run a cron job every X minutes?

Use */X in the minute field. Examples: */5 = every 5 minutes, */30 = every 30 minutes. Important: */5 executes at minutes 0, 5, 10, 15... not 5 minutes after the last one. If you need exact intervals from start, manually execute the first time.

Can I use cron syntax in web applications?

Yes, but not directly. Node.js applications use libraries like node-cron or agenda. In cloud services, you use cron syntax with EventBridge (AWS), Cloud Scheduler (GCP) or Azure Functions with timer triggers. The syntax is the same, but execution is managed by the provider, not by system cron.