Skip to content

Instantly share code, notes, and snippets.

@dArignac
Last active August 29, 2015 14:15
Show Gist options
  • Save dArignac/1260ea94585ddcef27d2 to your computer and use it in GitHub Desktop.
Save dArignac/1260ea94585ddcef27d2 to your computer and use it in GitHub Desktop.
YUM update check and mail notify
#!/bin/bash
SEND_TO=$1
UPDATES=`yum check-update -q | awk '{print $1}'`
UPDATE_COUNT=`printf "%s\n" "$UPDATES" | grep -v "^$" | wc -l`
UPDATE_TEXT=$(printf "%s\n" "${UPDATES}")
if [ "${UPDATE_COUNT}" -gt "0" ]; then
echo "${UPDATE_TEXT}" | mail -s "${UPDATE_COUNT} Yum-Updates are available" "${SEND_TO}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment