Skip to content

Cron Expression Cheat Sheet

A quick reference for writing cron expressions used in scheduled tasks.


Cron Format

Standard cron has 5 fields:

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

Some systems (like AWS) add a 6th field for seconds at the start.


Special Characters

Character Meaning Example
* Any value * * * * * = every minute
, List of values 1,15,30 = at 1, 15, and 30
- Range of values 1-5 = 1 through 5
/ Step values */15 = every 15 units

Common Examples

Every X Minutes

Expression Description
* * * * * Every minute
*/5 * * * * Every 5 minutes
*/15 * * * * Every 15 minutes
*/30 * * * * Every 30 minutes

Every X Hours

Expression Description
0 * * * * Every hour (on the hour)
0 */2 * * * Every 2 hours
0 */6 * * * Every 6 hours
30 * * * * Every hour at 30 minutes past

Daily

Expression Description
0 0 * * * Every day at midnight
0 6 * * * Every day at 6:00 AM
0 18 * * * Every day at 6:00 PM
0 9,18 * * * Every day at 9 AM and 6 PM

Weekly

Expression Description
0 0 * * 0 Every Sunday at midnight
0 0 * * 1 Every Monday at midnight
0 9 * * 1-5 Weekdays at 9:00 AM
0 0 * * 6,0 Weekends at midnight

Monthly

Expression Description
0 0 1 * * First day of every month at midnight
0 0 15 * * 15th of every month at midnight
0 9 1 * * First day of every month at 9:00 AM
0 0 1,15 * * 1st and 15th of every month

Yearly

Expression Description
0 0 1 1 * January 1st at midnight
0 0 1 */3 * First day of every quarter

Day of Week Reference

Number Day
0 Sunday
1 Monday
2 Tuesday
3 Wednesday
4 Thursday
5 Friday
6 Saturday

Some systems also accept SUN, MON, TUE, etc.


Month Reference

Number Month
1 January
2 February
3 March
4 April
5 May
6 June
7 July
8 August
9 September
10 October
11 November
12 December

Some systems also accept JAN, FEB, MAR, etc.


Special Strings

Some systems support these shortcuts:

String Equivalent Description
@yearly 0 0 1 1 * Once a year (Jan 1)
@monthly 0 0 1 * * Once a month (1st)
@weekly 0 0 * * 0 Once a week (Sunday)
@daily 0 0 * * * Once a day (midnight)
@hourly 0 * * * * Once an hour
@reboot - At startup

Real-World Examples

Business Hours

# Every 15 minutes during business hours (9 AM - 5 PM, Mon-Fri)
*/15 9-17 * * 1-5

Nightly Backup

# Every night at 2:30 AM
30 2 * * *

Weekend Maintenance

# Saturdays at 3:00 AM
0 3 * * 6

End of Month

# Last day of month at 11:59 PM (use day 28 to be safe)
59 23 28 * *

Every Quarter

# First day of Jan, Apr, Jul, Oct at 6:00 AM
0 6 1 1,4,7,10 *

AWS CloudWatch / EventBridge

AWS uses a slightly different format with 6 fields (includes year):

cron(minutes hours day-of-month month day-of-week year)

Examples:

cron(0 12 * * ? *)        # Every day at 12:00 PM UTC
cron(0/15 * * * ? *)      # Every 15 minutes
cron(0 9 ? * MON-FRI *)   # Weekdays at 9:00 AM

Note: AWS uses ? for "no specific value" in day-of-month or day-of-week.


Tips

  1. Test your expressions - Use a cron expression validator before deploying
  2. Consider timezones - Cron typically runs in the server's timezone
  3. Avoid midnight rush - Many jobs run at 0 0 * * *, consider offsetting
  4. Be specific - 0 9 * * * is better than * 9 * * * (once vs 60 times)
  5. Document your crons - Future you will thank present you