Skip to content

Commit a94d8ef

Browse files
hackertacoclaude
andcommitted
docs(readme): add day of month and day of week OR condition behavior
Clarifies that when both fields are specified with specific values, they create an OR condition (not AND), following standard POSIX cron behavior. Also mentions the # character syntax being considered in #877 as an alternative for patterns like "first Monday of the month". Closes #890 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8f8adfa commit a94d8ef

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@ day of week 0-7 (0 or 7 is Sunday, or use names)
280280

281281
- Using arrow functions for `onTick` binds them to the parent's `this` context. As a result, they won't have access to the cronjob's `this` context. You can read a little more in issue [#47 (comment)](https://github.com/kelektiv/node-cron/issues/47#issuecomment-459762775).
282282

283+
- When both `day of month` and `day of week` are specified with specific values (not `*`), they create an **OR condition**, not AND. This follows the standard POSIX cron behavior. For example:
284+
- `0 0 1-7 * 1` means "run at midnight on days 1-7 **OR** on any Monday", not "run on Mondays that fall within days 1-7".
285+
- `0 0 15 * 5` means "run on the 15th of any month **OR** on any Friday".
286+
287+
If either field is set to `*` (unrestricted), the relationship becomes AND:
288+
- `0 0 15 * *` means "run on the 15th of any month" (day of week is unrestricted).
289+
- `0 0 * * 1` means "run on any Monday" (day of month is unrestricted).
290+
291+
**Note:** Patterns like "first Monday of the month" cannot be directly expressed with standard cron syntax. A `#` character syntax (e.g., `0 0 * * 1#1` for "first Monday") is being considered in [#877](https://github.com/kelektiv/node-cron/pull/877). See [#890](https://github.com/kelektiv/node-cron/issues/890) for more details.
292+
283293
## 🤝 Community
284294

285295
Join the [Discord server](https://discord.gg/yyKns29zch)! Here you can discuss issues and get help in a more casual forum than GitHub.

0 commit comments

Comments
 (0)