Day-of-week: Allowed range 0 – 7. Sunday is either 0 or 7.
I found this after Googling, my question is why should both values (0,7) correspond to Sunday?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
This is a matter of portability. In early Unices, some versions of cron accepted 0 as Sunday, and some accepted 7 as Sunday -- this format is an attempt to be portable with both. From
man 5 crontab in vixie-cron (emphasis my own):
When specifying day of week, both day 0 and day 7 will be considered Sunday. BSD and AT&T seem to disagree about this.
In addition to @ChrisDown's excellent answer, this might also be a nifty solution to a localisation issue: "According to the Hebrew calendars and traditional Christian calendars, Sunday is the first day of the week." Having it both ways, which is really easy programmatically, makes it easy to use for either group.
There is widespread disagreement as to which day of the week makes sense to be considered the first.
Historically, our seven-day week comes from Genesis, in both the Hebrew Bible and the Christian Bible. But our modern lifestyle with Saturday and Sunday being considered "the weekend" obscures this, and makes it easy to think of Sunday as the last day instead of the first day.
Some natural languages actually encode the perspective of Sunday-as first-day or Sunday-as-last-day into their vocabulary, using ordinal names for some of the days, with Serbian and Portuguese being two examples. In Serbian, Petak means 5th day, but refers to Friday. In Portuguese, sexta-feira means 6th day, but refers to Friday.
In apps I use, some treat Sunday as the first day and others as the last day. Most calendar apps seem to allow the user to configure this, but not all apps do that.
The compromise made by
cron is quite clever, actually, allowing some users to have their preference as long as they are willing to use a 0-based array, and others to have theirs as long as they are willing to use a 1-based array.