From 7ee6a855343d05fefbc76c59b467a3c30a32093a Mon Sep 17 00:00:00 2001 From: Steffen Busch Date: Mon, 25 Nov 2024 22:32:56 +0100 Subject: [PATCH 1/3] Add "Advanced Cron Expressions" --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 863b36b..7d4bc16 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,25 @@ In this example, a promotional message is displayed during business hours from 0 └───────── Minute (0-59) ``` +#### Advanced Cron Expressions + +While the commonly used 5-segment cron format (` `) is supported, the underlying library ([Gronx](https://github.com/adhocore/gronx)) provides extended functionality with a 6-segment style that includes ``. This format allows for more precise scheduling: + +- A complete cron expression consists of 7 segments: ` `. +- For a 6-segment expression, if the 6th segment matches `` (e.g., at least 4 digits), it is interpreted as ` `. A default value of `0` is used for ``. + +Additionally, Gronx supports advanced modifiers for the `` and `` segments: + +- **`L` (Last)**: + - In the `` segment, `L` represents the last day of the month (e.g., `L` could mean February 29th in a leap year). + - In the `` segment, `L` refers to the last occurrence of a specific weekday in a month (e.g., `2L` means the last Tuesday of the month). +- **`W` (Weekday)**: + - For ``, `W` specifies the closest weekday (Monday to Friday) to a given day (e.g., `10W` means the closest weekday to the 10th of the month). +- **`#` (Nth weekday)**: + - In the `` segment, `#` denotes the nth occurrence of a specific day in a month (e.g., `1#2` means the second Monday of the month). + +For a complete overview of these features, refer to the [Gronx README](https://github.com/adhocore/gronx#readme). + ## License This project is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for details. From 9d153bd0fbac5d70bcbd660c146130cd1871469a Mon Sep 17 00:00:00 2001 From: Steffen Busch Date: Mon, 25 Nov 2024 23:01:55 +0100 Subject: [PATCH 2/3] Add example using advanced cron expression --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 7d4bc16..8367caf 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,32 @@ Additionally, Gronx supports advanced modifiers for the `` and `` For a complete overview of these features, refer to the [Gronx README](https://github.com/adhocore/gronx#readme). +#### Advanced Cron Expressions in Action + +These features enable precise and complex scheduling, such as Oracle's **Critical Patch Updates** that occur on the **third Tuesday of January, April, July, and October**. Below is an example demonstrating how to configure this in Caddy: + +```caddyfile +@criticalPatchTuesday cron "0 0 * 1,4,7,10 2#3" "0 23 * 1,4,7,10 2#3" + +handle @criticalPatchTuesday { + respond "Oracle Critical Patch Update in progress: Third Tuesday of January, April, July, and October." +} + +handle { + reverse_proxy localhost:8080 +} +``` + +Step-by-Step Breakdown of the Example: + +1. **`"0 0 * 1,4,7,10 2#3"`**: + - **`1,4,7,10`**: Matches the months **January, April, July, and October**. + - **`2#3`**: Matches the **third Tuesday** (weekday `2` for Tuesday and `#3` for the third occurrence of that day in the month). + - The day field (`*`) is ignored because the `2#3` modifier already specifies the exact match. + +2. **`"0 23 * 1,4,7,10 2#3"`**: + - Ends the match at 23:59 on the same day. + ## License This project is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for details. From e34f009dbfceebd64a18bb2a70e4d6f8219362ec Mon Sep 17 00:00:00 2001 From: Steffen Busch Date: Mon, 25 Nov 2024 23:12:36 +0100 Subject: [PATCH 3/3] Fix example --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8367caf..8a9d8b7 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,7 @@ For a complete overview of these features, refer to the [Gronx README](https://g These features enable precise and complex scheduling, such as Oracle's **Critical Patch Updates** that occur on the **third Tuesday of January, April, July, and October**. Below is an example demonstrating how to configure this in Caddy: ```caddyfile -@criticalPatchTuesday cron "0 0 * 1,4,7,10 2#3" "0 23 * 1,4,7,10 2#3" +@criticalPatchTuesday cron "0 0 * 1,4,7,10 2#3" "30 23 * 1,4,7,10 2#3" handle @criticalPatchTuesday { respond "Oracle Critical Patch Update in progress: Third Tuesday of January, April, July, and October." @@ -181,8 +181,8 @@ Step-by-Step Breakdown of the Example: - **`2#3`**: Matches the **third Tuesday** (weekday `2` for Tuesday and `#3` for the third occurrence of that day in the month). - The day field (`*`) is ignored because the `2#3` modifier already specifies the exact match. -2. **`"0 23 * 1,4,7,10 2#3"`**: - - Ends the match at 23:59 on the same day. +2. **`"30 23 * 1,4,7,10 2#3"`**: + - Ends the match at 23:30 on the same day. ## License