:tropical_drink: 一种简单、方便的方法来自动更新 Homebrew。
An easy, convenient way to automatically update Homebrew.
This script will run brew update in the background once every 24 hours (by
default) until explicitly told to stop, utilising launchd.
brew upgrade and brew cleanup can also be handled automatically, but
are optional flags.
Notifications are enabled by default using a code-signed, universal macOS app.
Pass --notify-on-error to suppress successful-run notifications, or
--no-notify to disable notifications entirely.
Tap the repository and trust its external command:
brew tap domt4/autoupdate
brew trust --command domt4/autoupdate/autoupdate
Homebrew is moving towards requiring explicit trust before loading commands
from non-official taps. Command-scoped trust is recommended here because it
permits only brew autoupdate; it does not trust every current or future
formula, cask, or command in this tap.
Existing users who see an untrusted tap warning can run the brew trust
command above. When trust enforcement is enabled, an already installed launch
agent will continue running its scheduled built-in brew update, upgrade,
and cleanup commands. Management commands such as brew autoupdate status,
stop, or delete will be unavailable until autoupdate is trusted.
See Homebrew's tap trust documentation and issue #222 for background.
Now run brew autoupdate start [interval] [options] to enable autoupdate.
The interval defaults to 24 hours and accepts seconds or a short duration such
as 30m, 12h, or 1d, or a 24-hour clock time such as 00:00 to run daily
at that specific time instead of relative to when the command was run.
Note:
To ensure that auto-updated cask-based apps are updated in place (so they stay on your Dock), add ~/Library/Application Support/com.github.domt4.homebrew-autoupdate/brew_autoupdate to System Settings / Privacy and Security / App Management. (Also allow ruby and Terminal.app)
brew autoupdate start 12h --upgrade --cleanup --immediate --sudo
This will upgrade all your casks and formulae every 12 hours and on every system boot. If a sudo password is required for an upgrade, a GUI to enter your password will be displayed. Also, it will clean up every old version and left-over files.
Casks that have built-in auto-updates enabled by default will not be upgraded.
brew autoupdate start 12h --upgrade --only=wget,node,firefox
This will only auto-upgrade wget, node, and firefox every 12 hours,
leaving all other installed packages untouched. Both formulae and casks are
supported, including tap-qualified names (homebrew/cask/firefox) and
versioned formulae (node@20).
Cannot be combined with --leaves-only. To change which packages are
auto-upgraded, run brew autoupdate delete then start again with the new list.
brew autoupdate start 00:00 --upgrade --cleanup
Instead of a duration, pass a 24-hour clock time (HH:MM) to schedule the run
via launchd's StartCalendarInterval at that exact wall-clock time every
day, rather than a relative interval measured from whenever the command was
run (which drifts and won't line up with midnight, or any other fixed time,
over repeated runs).
…
Logs of the performed operations can be found at: ~/Library/Logs/com.github.domt4.homebrew-autoupdate
brew's built-in autoupdate mechanismThis command mostly exists to ensure Homebrew is updated regardless of whether
you invoke brew or not, which is the primary difference from the autoupdate
mechanism built into brew, the latter requiring a user to explicitly run
any of brew install, brew tap or brew upgrade.
If you run brew commands regularly yourself, you may wish to consider using
the built-in autoupdate mechanism, which can be instructed to autoupdate less
often, or disabled entirely. If you wish to update every 24 hours using the
built-in autoupdate mechanism set this in your environment:
export HOMEBREW_AUTO_UPDATE_SECS="86400"
or if you wish to disable the built-in autoupdate mechanism entirely:
export HOMEBREW_NO_AUTO_UPDATE="1"
Please note that Homebrew slightly frowns upon people disabling the built-in autoupdate mechanism.
This tap was created by DomT4 in April 2015 to address a personal desire for a background updater, before being moved to the Homebrew organisation in April 2021 to become an official part of the project after gaining somewhat widespread usage, something I'm both surprised by, but also very appreciative of people finding a small tool I wrote so useful & contributing their own ideas and time towards.
It was in late 2023 moved back to DomT4's ownership to reduce the burden on the wider Homebrew leadership team in terms of maintenance/support requests.
Code is under the BSD 2 Clause (NetBSD) license.
暂无开放 Issues,或尚未同步最近议题。