Cron Expression Generator — Complete Guide
Learn how to create and understand cron expressions for scheduling tasks. Includes syntax, examples, and a free visual generator tool.
What is a Cron Expression?
A cron expression is a string consisting of five or six fields that define a schedule for running recurring tasks. It is used by Unix-like operating systems and many modern applications to automate jobs like backups, log rotation, email reports, and data synchronization.
Each field represents a time unit: minute, hour, day of month, month, day of week — and optionally, year. The cron daemon reads these expressions and executes the associated command when all fields match the current time.
Cron Syntax Reference
Standard cron format: minute (0-59), hour (0-23), day of month (1-31), month (1-12), day of week (0-6, Sunday=0). Example: '30 2 * * *' runs at 2:30 AM daily.
Special characters: * (any value), , (value list separator), - (range), / (step). Examples: '*/5' = every 5 units, '1-5' = 1 through 5, '1,3,5' = specific values.
Common shortcuts: '@hourly' = '0 * * * *', '@daily' = '0 0 * * *', '@weekly' = '0 0 * * 0', '@monthly' = '0 0 1 * *', '@yearly' = '0 0 1 1 *'.
Real-World Cron Examples
Run a database backup every day at 2:30 AM: '30 2 * * * /scripts/backup-db.sh'
Send a weekly report every Monday at 9 AM: '0 9 * * 1 /scripts/send-report.sh'
Clear log files every hour: '0 * * * * /scripts/clear-logs.sh'
Run a health check every 5 minutes: '*/5 * * * * /scripts/health-check.sh'
Synchronize data on the first day of every quarter: '0 0 1 1,4,7,10 * /scripts/sync-quarterly.sh'