/usr/local/scripts/account-exp
#!/bin/sh
#
# This script checks to see if an acount's password is expired and
# then sends me an email
#
#
##############
# Variables
##############
SERVERNAME=`uname -n`
file=/var/tmp/accounts
LOGFILE=/var/cron/log
WORD=expire
#########################################
# Check to see if there are
# any expired accounts
#########################################
EXPIRED=`grep ${WORD} ${LOGFILE} | wc -l`
#########################################
# If an expired account has
# been detected, email the administrator
#########################################
if [ ${EXPIRED} -ne 0 ]; then
# Attach a header
uname -a >$file
echo "">>$file
echo "**************************************************************" >> $fil
e
#
# Also attach expired info
grep expire ${LOGFILE} >> $file
#
# Now email the administrator
cat $file|mailx -s expired_accounts_$SERVERNAME me@myhost.com
#
# Clean up
rm $file
#
fi
Tuesday, December 30, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment