A small, dependency-free launchd agent that keeps Homebrew
updated once a day on macOS — reliably, even on a laptop that sleeps or
shuts down, and without ever granting passwordless sudo.
It runs brew update, brew upgrade (formulae + safe casks) and
brew cleanup on a daily schedule, then shows a desktop notification.
The popular DomT4/homebrew-autoupdate
tap is great, but its launchd agent uses StartInterval (a relative timer).
On a laptop that is asleep or powered off when the timer would fire, runs get
silently skipped and the relative timer resets on every reboot — so days
can pass with no update.
This project fixes that and adds a few practical safeguards:
| Concern | StartInterval (typical setup) |
brew-daily-autoupdate |
|---|---|---|
| Missed runs while asleep / off | Skipped, timer resets on reboot | StartCalendarInterval at 3 times/day; macOS catches up on next wake/boot |
| One cask failing aborts everything | && chain stops; cleanup never runs |
Every step is fault-tolerant; cleanup + notification always run |
| GUI apps that update themselves | May be force-upgraded with --greedy |
No --greedy → self-updating casks are skipped |
Casks that need sudo |
Often fail headless, or require passwordless sudo | Excluded by name — never edits /etc/sudoers |
| Running 3 times/day | Would upgrade repeatedly | Once-per-day stamp → real work runs once per calendar day |
The wrapper (brew_autoupdate) does, in order:
- Once-per-day guard — a stamp file (
last_run_date) ensures the heavy upgrade runs only once per calendar day, even though launchd triggers it at 09:00, 14:00 and 21:00. The extra slots exist purely so a machine that was asleep/off at 09:00 still gets caught later. brew updatethenbrew upgrade --formula.brew upgrade --caskwithout--greedy(so GUI self-updating apps are left alone), minus any cask matchingEXCLUDE_CASKS.brew cleanup.- A desktop notification via
osascript(no external dependency).
Every command is wrapped with || echo "[warn] ..." so a single failure logs a
warning and the chain continues — cleanup and the notification are never
skipped.
Some casks (e.g. charles, virtualbox) need sudo to upgrade. Granting a
background launchd job passwordless sudo would mean adding a NOPASSWD rule
to /etc/sudoers, which widens your attack surface.
This project does not do that. Such casks are simply listed in
EXCLUDE_CASKS and left for you to upgrade manually:
sudo brew upgrade --cask charles virtualboxThis tool never touches /etc/sudoers and never runs sudo.
git clone https://github.com/ChrisOr-Dev/brew-daily-autoupdate.git
cd brew-daily-autoupdate
./install.shinstall.sh copies the wrapper to
~/Library/Application Support/brew-daily-autoupdate/, renders the launchd
plist with absolute paths, and loads the agent. Apple Silicon (/opt/homebrew)
and Intel (/usr/local) prefixes are both detected automatically.
launchctl print "gui/$(id -u)/com.github.chrisor-dev.brew-daily-autoupdate" | grep -i state
tail -f ~/Library/Logs/brew-daily-autoupdate/com.github.chrisor-dev.brew-daily-autoupdate.log~/Library/Application\ Support/brew-daily-autoupdate/brew_autoupdate(Tip: delete ~/Library/Application Support/brew-daily-autoupdate/last_run_date
first if you already ran today and want to force a fresh run.)
Edit EXCLUDE_CASKS at the top of the installed wrapper
(~/Library/Application Support/brew-daily-autoupdate/brew_autoupdate). It is a
pipe-separated, whole-line match:
EXCLUDE_CASKS='charles|virtualbox|screaming-frog-seo-spider'Reasons you might exclude a cask:
- it requires
sudo(cannot upgrade in a headless launchd job), or - its upstream checksum drifts and repeatedly fails SHA-256 verification.
To change the schedule, edit the StartCalendarInterval block in
~/Library/LaunchAgents/com.github.chrisor-dev.brew-daily-autoupdate.plist,
then re-run ./install.sh (or launchctl bootout + bootstrap).
./uninstall.shThis unloads and removes the launchd agent. Logs and the wrapper directory are left in place; delete them manually if you want a clean sweep.
- macOS (tested on Apple Silicon)
- Homebrew
No taps, no extra packages, no sudo.
MIT — see LICENSE.