Listing 2: duck
#!/bin/sh
#
# check for users with lots of disk space used
#
MINUSERID=1000 # where your uids start
# (lowest "regular user")
MAXSIZE=10240 # max number of 512 byte blocks for trigger
# (10240 blocks = 5 megabytes)
#
# uncomment only one of the following two lines:
# PASSWD="cat /etc/passwd" # if not using NIS
PASSWD="ypcat passwd" # if using NIS
HOST=`hostname`
TMP=/tmp/duck.$$
rm -f $TMP
if [ -f /vmunix ]; then # get Berkeley df(1)
DFCOMMAND=/bin/df # if SunOS
else
DFCOMMAND=/usr/ucb/df # if SVR4
fi
touch $TMP
for i in `$PASSWD | awk -F: '{if ($3 > '$MINUSERID') print $6}'`
do
cd $i
x=`$DFCOMMAND . | grep "^/"`
if [ "$x" != "" ]; then # if local to this host
size=`du -s . | awk '{print $1}'`
if [ $size -gt $MAXSIZE ]; then
echo "$i ($size)" >>$TMP
fi
fi
done
n=`wc -l $TMP | awk '{print $1}'`
if [ $n -gt 0 ]; then
echo " "
echo "User directories on $HOST larger than $MAXSIZE 512-byte blocks:"
echo " "
sed 's/^/ /' $TMP
echo " "
fi
rm -f $TMP
|