What is Cron? Complete Guide with Examples

3 min readdeveloper

Last updated: Invalid Date

Cron is a time-based job scheduler in Unix-like operating systems that executes commands or scripts at specified times, dates, or intervals. Cron expressions are strings that define the schedule using five fields: minute, hour, day of month, month, and day of week. For example, '0 9 * * 1' means 'every Monday at 9:00 AM'. Cron is fundamental to system administration, DevOps, and backend development for automating recurring tasks.

Try It Yourself

Use our free Cron Expression Parser to experiment with cron expressions.

How Does Cron Expressions Work?

The cron daemon reads crontab files containing schedule entries and command pairs. Each entry specifies when to run (the cron expression) and what to run (the command). The daemon checks every minute if any scheduled time matches the current time. Cron expressions use five space-separated fields: minute (0-59), hour (0-23), day of month (1-31), month (1-12), day of week (0-7). Special characters include * (any), , (list), - (range), / (step), and some implementations support @yearly, @monthly, @weekly, @daily shorthands.

Key Features

  • Five-field syntax covering minute, hour, day-of-month, month, and day-of-week
  • Special characters: * (any value), , (value list), - (range), / (step/interval)
  • Shorthand macros like @daily, @weekly, @monthly, @yearly for common schedules
  • Human-readable description generation from cron expressions
  • Next-run calculation showing upcoming execution times for verification

Common Use Cases

Database Backups

System administrators schedule nightly database backups using cron: '0 2 * * *' runs the backup script at 2:00 AM every day, ensuring data is regularly protected.

Report Generation

Business applications generate weekly reports on schedule: '0 8 * * 1' produces and emails the report every Monday at 8:00 AM.

Cache Cleanup

DevOps teams schedule periodic cleanup of temporary files, expired cache entries, and old logs to prevent disk space issues: '0 */6 * * *' runs every 6 hours.

Why Cron Expressions Matters

Understanding cron expressions is essential for anyone working in software development. It is not just a theoretical concept — it directly impacts the quality, efficiency, and reliability of your work. Professionals who understand the underlying principles make better decisions about which tools and approaches to use.

Whether you are a beginner learning the fundamentals or an experienced professional looking for a quick refresher, grasping how cron expressions works helps you debug issues faster, communicate more effectively with your team, and choose the right tool for each specific task.

Getting Started with Cron Expressions

The fastest way to learn cron expressions is to experiment with it hands-on. Use our free tools linked above to try different inputs and see how the output changes. Start with simple examples, then gradually increase complexity as you build intuition for how cron expressions behaves.

For deeper learning, explore the related guides linked at the bottom of this page — they cover adjacent concepts that will strengthen your understanding of the broader ecosystem. Each guide includes practical examples and links to tools you can use immediately.

Frequently Asked Questions

What does * * * * * mean in cron?
Five asterisks mean 'every minute of every hour of every day of every month on every day of the week' — the command runs once per minute. Each asterisk is a wildcard matching all values for its field.
How do I run a cron job every 5 minutes?
Use */5 * * * * — the */5 in the minute field means 'every 5th minute'. This runs at minutes 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, and 55 of every hour.
What is the difference between cron and crontab?
Cron is the daemon (background service) that runs scheduled jobs. Crontab (cron table) is the file listing the schedules and commands. 'crontab -e' edits your crontab, 'crontab -l' lists it.
Can cron run jobs every 30 seconds?
Standard cron has a minimum granularity of one minute. To run every 30 seconds, schedule the command at * * * * * and add a second entry with 'sleep 30 &&' prefix, or use systemd timers which support sub-minute intervals.

Related Guides

Related Tools

Was this page helpful?

Written by

Tamanna Tasnim

Senior Full Stack Developer

ToolsContainerDhaka, Bangladesh5+ years experiencetasnim@toolscontainer.comwww.toolscontainer.com

Full-stack developer with deep expertise in data formats, APIs, and developer tooling. Writes in-depth technical comparisons and conversion guides backed by hands-on engineering experience across modern web stacks.