Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
Created September 4, 2011 06:37
Show Gist options
  • Select an option

  • Save michaelficarra/1192402 to your computer and use it in GitHub Desktop.

Select an option

Save michaelficarra/1192402 to your computer and use it in GitHub Desktop.
/etc/cron.daily/yum-update.sh
#!/bin/bash
yum=/usr/bin/yum
"$yum" check-update &> /dev/null
[ 0 -eq $? ] && exit 0
"$yum" -y -e 0 -R 10 update yum &> /dev/null
updated=`"$yum" -y -e 0 -R 120 --skip-broken update 2>&1`
num_updated=`echo "$updated" \
| grep -ix "Upgrade\\s\+[0-9]\+\\s\+Package(s)" \
| sed -e 's/Upgrade\s\+\([0-9]\+\)\s\+Package(s)/\1/'`
packages=packages
[ 0 = "$num_updated" ] && packages=package
echo "$updated" \
| mail -s "$(hostname): updated $num_updated $packages" root
"$yum" clean packages &> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment