Usually, I update brew/cask tools using bash function with a commands listed below:
brew update
brew upgrade
brew cleanup --force
brew cask cleanup --force
brew prune
find /Library/Caches/Homebrew/ -type f -ls -delete 2> /dev/null
To create a daemon, save this text to ~/Library/LaunchAgents/com.example.homebrew-upgrade.plist
:
<?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>Label</key>
<string>com.example.homebrew-upgrade</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>/usr/local/bin/brew update &&
/usr/local/bin/brew upgrade &&
/usr/local/bin/brew cleanup --force &&
/usr/local/bin/brew cask cleanup --force &&
/usr/local/bin/brew prune &&
/usr/bin/find /Library/Caches/Homebrew/ -type f -ls -delete 2> /dev/null </string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/com.example.homebrew-upgrade.stderr</string>
<key>StandardOutPath</key>
<string>/tmp/com.example.homebrew-upgrade.stdout</string>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>8</integer>
</dict>
</array>
</dict>
</plist>
And run the daemon:
launchctl load ~/Library/LaunchAgents/com.example.homebrew-upgrade.plist
You're awesome!