mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-03-02 22:57:00 -05:00
Possible to add a way to schedule maintenance every first Monday, Tuesday, etc...? #2204
Labels
No labels
A:accessibility
A:api
A:cert-expiry
A:core
A:dashboard
A:deployment
A:documentation
A:domain expiry
A:incidents
A:maintenance
A:metrics
A:monitor
A:notifications
A:reports
A:settings
A:status-page
A:ui/ux
A:user-management
Stale
ai-slop
blocked
blocked-upstream
bug
cannot-reproduce
dependencies
discussion
duplicate
feature-request
feature-request
good first issue
hacktoberfest
help
help wanted
house keeping
invalid
invalid-format
invalid-format
question
releaseblocker 🚨
security
spam
type:enhance-existing
type:new
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/uptime-kuma#2204
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @b-a0 on GitHub (May 22, 2023).
⚠️ Please verify that this feature request has NOT been suggested before.
🏷️ Feature Request Type
Other
🔖 Feature description
The maintenance scheduler allows scheduling with cron. While cron on Debian allows one to schedule something on the first Monday (or Tuesday) of a month, the used cron library
cronerdoes not.However,
cronerdoes offer a legacy mode that would check the date of month and day of week conditions with anANDoperator instead of the defaultORoperator.✔️ Solution
By adding a checkmark next to the cron expression that would toggle
cronerlegacy mode, you could create a cron expression:Without the legacy box unchecked (as it is now) this would be:
With the legacy box checked:
❓ Alternatives
I have tried different cron expressions listed in this Superuser post. Unfortunately none of them work with the
cronerlibrary.📝 Additional Context
I only have a very rough understanding of JS, but to me it seems that a change would be needed in
/server/model/maintenance.js#L264. Something like this fake code:and in the UI around
/src/pages/EditMaintenance.vue#L94.@CommanderStorm commented on GitHub (May 23, 2023):
I would not like to add this additional feature.
Any variable prefixed with
legacyis something, that I would expect will not be there forever. => this would likely unexpectedly break in the future.Would
0 0 0 * * L1work for you?@b-a0 commented on GitHub (May 23, 2023):
Thanks for the suggestion. My understanding is that the
Lparameter schedules something on the last specified weekday of the month. I am looking to schedule something on the first Wednesday of the month, not the last, i.e.0 18 1-7 * 3 { legacyMode: false }.Is it possible to do that as well in the current version of Uptime Kuma?
I am not sure "legacy" refers to this being ready to deprecate in this case. Note also that it is set to
trueby default. I will check in the linked croner issue what their intentions are with this parameter.@Hexagon commented on GitHub (May 23, 2023):
Setting legacyMode to false is perfectly safe and a permanent feature of croner.
The default will always be legacyMode: true, which makes croner work like legacy cron parsers, which is expected behaviour, even though it's not optimal.
Confusing - yes! Need to worry - no 😄
@CommanderStorm commented on GitHub (May 25, 2023):
@b-a0
Would adding such a toggle in the settings also solve #2621?
What do you think would be a good UI for this? (what kind of help text + what input element)
@b-a0 commented on GitHub (May 25, 2023):
I think so, it seems to work for second and third $dayOfWeek.
Here are a few
cronerexamples (all withlegacyMode: false) which I've double checked with Excel for 2023 (marked with a ✔️ if it was the same):First Monday:
0 18 1-7 * 1✔️First Wednesday:
0 18 1-7 * 3✔️Second Tuesday:
0 18 8-14 * 2✔️Second Friday:
0 18 8-14 * 5✔️Third Monday:
0 18 15-21 * 1✔️Third Sunday:
0 18 15-21 * 7✔️I'm not well versed in web-design, but as a user I think a checkbox (that is unchecked by default) next to the cron textbox would make sense:
Checking the checkbox would set
legacyMode: false.Regarding the helptext, something similar to the Cloudflare settings page would probably be clear in terms of formatting:
The text (in light gray) could say something like:
Instead of the croner issue, it could also link to the current issue.
Hope this helps? Let me know if I can provide anything else.
@louislam commented on GitHub (May 26, 2023):
The checkbox should be easy to be implemented.
But the cron description (This message:
Schedule: At 06:00 PM, between day 1 and 7 of the month only if a Monday) maybe a bit hard to implement, because it is actually generated by another library called crontrue.@b-a0 commented on GitHub (May 29, 2023):
That is tricky indeed. I see two options, both are less than elegent unfortunately:
legacyMode: false) the text returned bycrontrueis slightly alterend. A few examples:0 18 1-7 * 1, instead of: "At 06:00 PM, between day 1 and 7 of the month, and on Monday", replace the last "and" with "only": "At 06:00 PM, between day 1 and 7 of the month, only on Monday".0 18 15-21 * 7would result in "At 06:00 PM, between day 15 and 21 of the month, only on Sunday"0 18 15-21 * 1,2,3,4would result in "At 06:00 PM, between day 15 and 21 of the month, only on Monday, Tuesday, Wednesday, and Thursday"0 18 15-21 * 1-5currenly returns "At 06:00 PM, between day 15 and 21 of the month, Monday through Friday". You would need to somehow add "only" between the comma and "Monday".This does not take into account internationalisation with i18n...
legacyMode: false) reparse the provided cron expression and use the#symbol in the day-of-week field to indicate the Nth day (which is supported bycronstrue, but not bycroner). Some examples:0 18 1-7 * 1->0 18 1-7 * 1#1: "At 06:00 PM, between day 1 and 7 of the month, on the first Monday of the month"0 18 1-7 * 1,2->0 18 1-7 * 1#1,2#1: "At 06:00 PM, between day 1 and 7 of the month, on the first Monday and first Tuesday of the month"0 18 8-14 * 1-4->0 18 8-14 * 1#2-4#2: "At 06:00 PM, between day 8 and 14 of the month, second Monday through second Thursday"In the second option there is a bit of redundancy there as it specifies both "between day X and Y of the month" and "Nth day of the week".
@CommanderStorm commented on GitHub (May 29, 2023):
I thought about this a bit more:

Maybe a global toggle for this would not be super intuitive. I think adding
nth-week of the monthhere would be more elegant (and most importantly, less confusing):I don't fully know how specifically, though.
strategyRestrict to-selector with["1st Week of the month","2nd Week of the month","3rd Week of the month", "last occurrance in month"])Both sound like a messy idea, though.
On the other hand, adding a toggle box (with an appropriate tooltip, explaining how n-th day of the week could work) here could also make sense

Connect Days of the week and Dates using->AND/OR,ORbeing the default:@Hexagon commented on GitHub (Aug 8, 2023):
Proper support for nth weekday of month through
#specifier is now released in the dev-channel of croner. Progress tracked at https://github.com/Hexagon/croner/issues/198 and will be released in7.0.0within a week.This will enable patterns such as
0 0 0 * * FRI#2or0 0 0 * * 5#2for second friday of month, and it will be possible to combine with other features, such as names, ranges andLto make more complex constructs - such as0 0 0 * * MON-FRI#Lfor every last weekday of the month.@NoeMeinhardt commented on GitHub (Feb 14, 2024):
Any progress on this? The data center we use performs scheduled maintenance every third Saturday and Sunday of the month. I would love to use
0 0 0 * * 6#2with a duration of 2879 minutes, but it says it "contains illegal characters".@CommanderStorm commented on GitHub (Feb 14, 2024):
The reason why this is not avaliable is that we have not found the time to migrate croner to v7. See
github.com/louislam/uptime-kuma@cf2d603e27/package.json (L92)This change either needs calling out or a migration:
Here is our contribution guide: https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md