Cron is a time-based job scheduler used in Unix-like systems to run commands at specified intervals. Understanding cron expressions is essential for system administration and automation.
Cron Expression Format
A cron expression has five fields:
┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of month (1 - 31)
│ │ │ ┌───────────── month (1 - 12)
│ │ │ │ ┌───────────── day of week (0 - 6)
│ │ │ │ │
* * * * *
Special Characters
*- Any value,- List separator (1,3,5)-- Range (1-5)/- Step values (*/15)
Common Examples
* * * * * | Every minute |
0 * * * * | Every hour |
0 0 * * * | Daily at midnight |
0 9 * * 1-5 | Weekdays at 9am |
0 0 1 * * | First day of each month |
*/15 * * * * | Every 15 minutes |
Best Practices
- Start with simple expressions and add complexity
- Test expressions before deploying
- Consider time zones
- Log job executions for debugging
- Handle overlapping executions
Use our Cron Expression Generator to build and understand cron schedules visually.