Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable scheduling of autoupdate with a cron like syntax brew autoupdate subcommand [schedule/interval] [options] #119

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

swissbuechi
Copy link
Contributor

Solves issue: #59

You know have the option to pass a cron like schedule definition to the start command instead of an interval.
The main goal was to provide a fix for skipped executions when the computer is asleep during the time an interval should be triggered. This can result in skipped updates and therefore vulnerable devices.

Usage

output from --help:

...
A schedule is a string of five hyphen-separated digits in a cron like format.
Minute(0-59)-Hour(0-23)-Day(1-31)-Weekday(0-7)-Month(1-12)
Missing values are considered wildcards.
For example: brew autoupdate start 0-12--- would run autoupdate every day at noon (12:00).
For more information on StartCalendarInterval, see man launchd.plist.

A interval has to be passed in seconds, so 12 hours would be
brew autoupdate start 43200.
The exact time of execution depends on the last system boot.
If the computer is asleep at the scheduled time, the interval will be skipped.
This could lead to skipped intervals and is therefor not a recommended option.
Use a schedule instead.
...

Error handling

Invalid character

~ » brew autoupdate start 0-12-T--
Error: Error: Schedule (Minute:0, Hour:12, Day:T, Weekday:any, Month:any) contains invalid character 'T' in Day at position 3. Must be a digit or empty.

Invalid value

~ » brew autoupdate start 0-25---
Error: Error: Schedule (Minute:0, Hour:25, Day:any, Weekday:any, Month:any) is outside the allowed range '25' in Hour at position 2. Allowed range Hour: 0-23.

Invalid pattern
If the pattern is not recognized (missing one hyphen, for example), it will show the output of --help followed by this line:

Error: Invalid usage: This subcommand only accepts a schedule pattern or interval integer as argument.

Additional infos

Please refer to this comment for a more in depth explanation of the solved problem. You will also find a sample of how StartInterval is different from StartCalendarInterval regarding the plist XML definition.

The interval option is still supported and can be used like before.
When the user does not specify a custom interval or custom schedule, it will fall back to 0-12---:

This script will run brew update in the background every day at noon (12:00)
(by default) until explicitly told to stop, utilizing launchd. If the computer
is asleep at the scheduled time, it will start as soon the computer is awake.

@swissbuechi swissbuechi marked this pull request as draft November 13, 2023 14:01
@swissbuechi swissbuechi marked this pull request as ready for review November 28, 2023 18:35
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the Stale label Dec 20, 2023
@swissbuechi
Copy link
Contributor Author

not stale

@github-actions github-actions bot removed the Stale label Dec 26, 2023
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the Stale label Jan 20, 2024
@swissbuechi
Copy link
Contributor Author

not stale

@github-actions github-actions bot removed the Stale label Jan 21, 2024
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the Stale label Feb 12, 2024
@swissbuechi
Copy link
Contributor Author

not stale

@github-actions github-actions bot removed the Stale label Feb 15, 2024
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@swissbuechi swissbuechi marked this pull request as draft January 20, 2025 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants