What is Cron? Complete Guide with Examples
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.
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?
How do I run a cron job every 5 minutes?
What is the difference between cron and crontab?
Can cron run jobs every 30 seconds?
Related Guides
Related Tools
Was this page helpful?
Written by
Tamanna Tasnim
Senior Full Stack Developer
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.