Skip to content

Instantly share code, notes, and snippets.

@creamidea
Forked from jb510/ReadMe.md
Created March 30, 2017 04:03
Show Gist options
  • Save creamidea/4dfa5ac37ebc349aedfeed796a01c230 to your computer and use it in GitHub Desktop.
Save creamidea/4dfa5ac37ebc349aedfeed796a01c230 to your computer and use it in GitHub Desktop.
OS X LaunchD job and script to automaticaly update homebrew
1. Place homebrewupdate.sh where ever you like, I use ~/bin/homebrewupdate.sh
2. Place the .plist file in ~/Library/LaunchAgents and update the path to your bash script
3. run 'launchctl load ~/Library/LaunchAgents/com.jb510.homebrewupdate.plist' or whatever you've named your plist file.
4. check 'launchctl list | grep jb510' to see that it's running
Note: you might need to `chmod +x homebrewupdate.sh`
<?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.jb510.homebrewupdate.plist</string> <!-- UPDATE file name -->
<key>ProgramArguments</key>
<array>
<string>/Users/jon/bin/ale.sh</string> <!-- UPDATE file name -->
</array>
<key>Nice</key>
<integer>1</integer>
<key>StartInterval</key>
<integer>21600</integer> <!-- UPDATE interval in seconds -->
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/jb510.homebrewupdate.err</string> <!-- UPDATE name/path -->
<key>StandardOutPath</key>
<string>/tmp/jb510.homebrewupdate.out</string><!-- UPDATE name/path -->
</dict>
</plist>
#!/bin/bash
echo ""
echo "`date`: RUNNING: brew update"
/usr/local/bin/brew update
echo "`date`: FINISHED: brew update"
echo ""
echo "`date`: RUNNING: brew upgrade"
/usr/local/bin/brew upgrade
echo "`date`: FINISHED: brew upgrade"
echo ""
echo "`date`: RUNNING: brew cleanup"
/usr/local/bin/brew cleanup
echo "`date`: FINISHED: brew cleanup"
echo ""
echo "All done! Enjoy a cold one! 🍺 "
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment