Skip to content

Instantly share code, notes, and snippets.

@boneskull
Last active November 8, 2023 20:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boneskull/c578346195eed967e4dd21e4f26e5f04 to your computer and use it in GitHub Desktop.
Save boneskull/c578346195eed967e4dd21e4f26e5f04 to your computer and use it in GitHub Desktop.
user launch agent to update & upgrade Homebrew daily

org.boneskull.homebrew-upgrade

This launch agent will automatically update & upgrade Homebrew every day. Upon success, it will send a notification.

UPDATED Nov 7 2023

Installation

  1. Install Homebrew.
  2. Install terminal-notifier. Execute brew install terminal-notifier.
  3. Copy the .plist file in this gist into ~/Library/LaunchAgents/.
  4. Execute launchctl load ~/Library/LaunchAgents/org.boneskull.homebrew-upgrade.plist. Do not run this command with superuser privileges.

Notes

  • Clicking on the thing should open the log file in whatever opens .log files by default (usually Console.app)
  • I've had something similar working from Yosemite through Sonoma.
  • This launch agent will run at load, and every 24h thereafter.

TODO

  • Report errors
  • Better interaction
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/homebrew/bin</string>
</dict>
<key>Label</key>
<string>org.boneskull.homebrew-upgrade</string>
<key>LowPriorityIO</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>brew update &amp;&amp; brew upgrade &amp;&amp; brew cleanup -s &amp;&amp; terminal-notifier -t Homebrew -message 'Homebrew upgraded!' -timeout 10 -open file:///tmp/org.boneskull.homebrew-upgrade.log -group org.boneskull.hombrew-upgrade -contentImage http://cldup.com/YVZi9Cuvhv.png</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/org.boneskull.homebrew-upgrade.err.log</string>
<key>StandardOutPath</key>
<string>/tmp/org.boneskull.homebrew-upgrade.log</string>
<key>StartInterval</key>
<integer>86400</integer>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment