:-) Sunday | 0 -> Sun
|
Monday | 1 -> Mon
Tuesday | 2 -> Tue
Wednesday | 3 -> Wed
Thursday | 4 -> Thu
Friday | 5 -> Fri
Saturday | 6 -> Sat
|
:-) Sunday | 7 -> Sun
As you can see above, and as said before, the numbers 0
and 7
are both assigned to Sunday. There are also the English abbreviated days of the week listed, which can also be used in the crontab.
Examples of Number or Abbreviation Use
15 09 * * 5,6,0 command
15 09 * * 5,6,7 command
15 09 * * 5-7 command
15 09 * * Fri,Sat,Sun command
The four examples do all the same and execute a command every Friday, Saturday, and Sunday at 9.15 o'clock.
In Detail
Utilising both 0
and 7
to represent Sunday is advantageous for creating weekday ranges[*] that start or end with Sunday, such as 0-2
or 5-7
. Ranges must start with the lower number and finish with the higher number. It's important to note that abbreviations cannot be used to define a weekday range with a hyphen-minus character. For example, you cannot shorten Fri,Sat,Sun
to Fri-Sun
.
[*] In the context of a crontab, a range is used to specify a continuous sequence of time units, such as minutes, hours, days, or weekdays. Ranges in crontab are represented using a hyphen-minus character (-) between the lower and upper bound values. For instance, a range of weekdays from Monday (1) to Wednesday (3) would be represented as 1-3
.