Defining Cron Expressions
A cron expression is a string that is used to define the exact time or a recurring interval for executing automated tasks, known as cron jobs.
Structure
In standard Linux syntax, a cron expression consists of five fields separated by spaces. The fields represent the following time values:
* * * * *
Minute
0 - 59
* * * * *
Hour
0 - 23
* * * * *
Day of the Month
1 - 31
* * * * *
Month (January–December)
1 - 12
* * * * *
Day of the Week (Sun–Sat)
0 - 6
Syntax Options
You can combine various numbers, letters, and special characters to create precise schedules. Here you can find available characters with corresponding examples:
*
This character represents a wildcard.
* * * * *
Every minute
*/<Number>
This expression represents an interval.
* /5 * * * *
Every 5 minutes
<Number>-<Number>
This expression represents a range of values.
0 9-17 * * 1-5
Every minute from 9:00 a.m. to 5:59 p.m., Monday through Friday
<Number>,<Number>,<Number>
This expression represents a list of multiple values.
0 8,12,16 * * *
At 8:00 a.m., 12:00 p.m., and 4:00 p.m.
<Number>-<Number>/<Number>
This expression combines an interval with a range of values.
0 1-6/2 * * *
Every 2 hours from 1:00 a.m. to 6:59 a.m.
<Number>L
This expression represents the last occurrence of a value.
0 20 * * 5L
At 8:00 p.m. on the last Friday of every month
<Number>#<Number>
This expression represents the nth occurrence of a value.
0 8 * * 1#2
At 8:00 a.m. on the second Monday of every month
Last updated
Was this helpful?