appzasGamesToolsDevLearnCheat sheetsQuick calcsConvertersReferenceNetworkTimeCalculatorsCompareLLM prices

How cron expressions work

Lesson 1 of 58 minBeginner

Read and write the five-field schedule that cron uses.

Cron is the classic Unix job scheduler. A background service (cron or crond) reads a table of schedules and runs each command when its time comes.

The five fields

# ┌ minute (0-59)
# │ ┌ hour (0-23)
# │ │ ┌ day of month (1-31)
# │ │ │ ┌ month (1-12)
# │ │ │ │ ┌ day of week (0-7, 0 and 7 are Sunday)
# │ │ │ │ │
  * * * * *  command to run
SymbolMeaningExample
*every value* * * * * every minute
,a list0 9,17 * * * at 09:00 and 17:00
-a range0 9 * * 1-5 at 09:00 Monday to Friday
/a step*/15 * * * * every 15 minutes

Examples

  • 30 2 * * * every day at 02:30.
  • 0 0 1 * * at midnight on the first day of each month.
  • */5 * * * * every five minutes.
  • 0 8 * * 1 every Monday at 08:00.

CarefulIf you set both day of month and day of week, most cron versions run the job when either matches, not both. Avoid mixing them.

NoteMany cron versions also accept shortcuts such as @daily, @hourly, @weekly and @reboot.

Test yourself

Answer all the questions, then check them. Finish with every answer right to mark the lesson as done.

1. When does "0 9 * * 1-5" run?
2. What does */15 in the minute field mean?
HintMinute 30, hour 2, then three stars.

Key terms