Skip to content

Instantly share code, notes, and snippets.

@boogah
Last active July 11, 2022 00:32
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save boogah/cdbbd337b0b447175061 to your computer and use it in GitHub Desktop.
Save boogah/cdbbd337b0b447175061 to your computer and use it in GitHub Desktop.
Never think about maintaining your homebrew install again with this shitty (but useful) shell script & cron job!
#!/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 ""
MAILTO=""
0 9,21 * * * /Users/USERNAME/scripts/ale.bash >> /Users/USERNAME/logs/ale.log
@kmplngj
Copy link

kmplngj commented Mar 24, 2019

Thanks!

@landonstewart
Copy link

landonstewart commented Mar 25, 2021

Add 2>&1 to the end of that cron so any output on stderr also hit the log file.

eg:

0 9,21 * * * /Users/USERNAME/scripts/ale.bash >> /Users/USERNAME/logs/ale.log 2>&1

Or just ignore all the output (runs every 6 hours starting at midnight, 6am, etc)

30 */6 * * *     /usr/local/bin/brew update > /dev/null 2>&1 && /usr/local/bin/brew upgrade > /dev/null 2>&1 && /usr/local/bin/brew cleanup > /dev/null 2>&1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment