Cron Expressions Explained: Scheduling Tasks Like a Pro
Back to Articles
DevOps

Cron Expressions Explained: Scheduling Tasks Like a Pro

Master cron expression syntax with this comprehensive guide. Learn the five-field format, special characters, common patterns, and how to avoid scheduling mistakes.

DailyUtil Team May 17, 2026 1 min read 0 words
Cron Expressions Explained: Scheduling Tasks Like a Pro

What Is a Cron Expression?

A cron expression is a string of five (or six) fields that defines a schedule for recurring tasks. Originally from Unix, cron is now used across Linux servers, CI/CD pipelines, cloud functions, and task schedulers everywhere.

The Five-Field Format

┌───────── minute (0-59)
│ ┌─────── hour (0-23)
│ │ ┌───── day of month (1-31)
│ │ │ ┌─── month (1-12)
│ │ │ │ ┌─ day of week (0-7, 0 and 7 = Sunday)
│ │ │ │ │
* * * * *

Special Characters

CharMeaningExample
*Every value* * * * * = every minute
,List1,15 * * * * = minute 1 and 15
-Range9-17 * * * * = hours 9 through 17
/Step*/15 * * * * = every 15 minutes

Common Patterns

ExpressionSchedule
* * * * *Every minute
0 * * * *Every hour (at :00)
0 0 * * *Daily at midnight
0 0 * * 1Every Monday at midnight
0 0 1 * *1st of every month
*/15 * * * *Every 15 minutes
0 9-17 * * 1-5Weekdays, 9am–5pm, hourly
0 0 1 1 *Yearly - January 1st at midnight
30 4 * * *Daily at 4:30 AM
0 */2 * * *Every 2 hours

Real-World Use Cases

Database Backups

0 2 * * * /usr/local/bin/backup-db.sh

Run a database backup every day at 2:00 AM.

Log Rotation

0 0 * * 0 /usr/sbin/logrotate /etc/logrotate.conf

Rotate logs every Sunday at midnight.

Cache Clearing

*/30 * * * * curl -X POST https://api.example.com/cache/clear

Clear cache every 30 minutes.

SSL Certificate Renewal

0 3 1 * * certbot renew --quiet

Attempt certificate renewal on the 1st of every month at 3:00 AM.

Common Mistakes

  1. Forgetting the month/day-of-week fields - all five fields are required
  2. Confusing day-of-week numbering - 0 and 7 both mean Sunday (system-dependent)
  3. Setting both day-of-month AND day-of-week - this creates an OR condition, not AND
  4. Not accounting for timezone - cron typically runs in the server's local timezone
  5. Overlapping executions - if a job takes 5 minutes but runs every minute, you'll have 5 concurrent instances

Build Your Own

Use our Cron Expression Generator to build and validate cron expressions with an interactive visual builder - see the next 10 execution times instantly.

Share this article