https://github.com/subconsciouscompute/cron-within-interval
Extended cron shorthands that randomly select value from interval
https://github.com/subconsciouscompute/cron-within-interval
cron cronjob-scheduler rust
Last synced: 8 months ago
JSON representation
Extended cron shorthands that randomly select value from interval
- Host: GitHub
- URL: https://github.com/subconsciouscompute/cron-within-interval
- Owner: SubconsciousCompute
- License: mit
- Created: 2023-12-15T10:11:54.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-12T16:47:36.000Z (11 months ago)
- Last Synced: 2025-01-04T12:12:49.952Z (9 months ago)
- Topics: cron, cronjob-scheduler, rust
- Language: Rust
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/SubconsciousCompute/cron-with-randomness/actions/workflows/rust.yml)
# cron-with-randomnessExtended cron shorthand to randomly select value from given interval. In addition to standard expression
supported by crate cron, this crate supports following shorthands.- `@daily{h=9-17}` means run once between 9 am and 5 pm chosen randomly.
- `@daily{h=9-12,h=15-20}` means run once between 9 am and 12 pm or between 3 pm and 8 pm.Similarly one can pass daily constraints to @weekly.
- `@weekly{d=1-5}` means run once per week between day 1 and day 5.
- `@weekly{d=1-5,h=9-12}` run once per week between day 1 and day 5 and between 9 am
and 12 pm.
- `@weekly{h=9-12}` runs once per week on any day chosen randomly and between 9 am
and 12 pm.# Examples
## `@daily`
```
$ cargo run -- @daily{h=9-17}--> 2023-12-18T13:17:00Z
--> 2023-12-19T09:52:00Z
--> 2023-12-20T13:12:00Z
--> 2023-12-21T16:44:00Z
--> 2023-12-22T09:09:00Z
--> 2023-12-23T09:37:00Z
--> 2023-12-24T16:55:00Z
--> 2023-12-25T12:28:00Z
--> 2023-12-26T16:36:00Z
--> 2023-12-27T10:35:00Z
```
## `@weekly````
$ cargo run -- @weekly{h=0-2}--> 2023-12-24T00:16:00Z
--> 2023-12-31T00:06:00Z
--> 2024-01-07T00:28:00Z
--> 2024-01-14T00:24:00Z
--> 2024-01-21T00:43:00Z
--> 2024-01-28T00:33:00Z
--> 2024-02-04T01:20:00Z
--> 2024-02-11T00:28:00Z
--> 2024-02-18T00:04:00Z
--> 2024-02-25T01:22:00Z
``````
$ cargo run -- '@weekly{d=1-4,h=0-2}'
--> 2023-12-25T01:51:00Z
--> 2024-01-03T01:02:00Z
--> 2024-01-09T00:27:00Z
--> 2024-01-15T01:10:00Z
--> 2024-01-24T01:10:00Z
--> 2024-01-30T00:53:00Z
--> 2024-02-07T00:31:00Z
--> 2024-02-13T00:18:00Z
--> 2024-02-19T00:35:00Z
--> 2024-02-26T01:16:00Z
```