Quick Quota Calculator for Cpanel Users

Print Friendly

To get an instant view of the diskspace being used by each Cpanel user account home directory, I created this little script. Thanks to Spiral for some pointers on getting the cleaned account list.

#!/bin/bash
#
CPUSERS=`/bin/ls -- /var/cpanel/users | /bin/grep -v "\.\|cpanel\|root\|mysql\|nobody"`
TOT=1
for CPUSER in $CPUSERS; do
   CPHOME="$(/bin/grep "${CPUSER}:" /etc/passwd | cut -d':' -f6)"
   NEWACC="`/usr/bin/du -m --summarize $CPHOME`"
   S="`printf \"%03d\" $(echo $NEWACC | awk '{print $1}')`"
   let "TOT=$TOT+$(echo $NEWACC | awk '{print $1}')/1"
   ACCSUM=$ACCSUM"\n"$S" "$CPHOME
done
echo -e $ACCSUM | sort
echo $TOT

As always, do not test in a production environment!

Tags: ,

No comments yet.

Leave a Reply

Bot test *