disk quota shell script

  • taqqi
  • Born
  • Born
  • taqqi
  • Posts: 3

Post 3+ Months Ago

hi guys!
I implemented disk quota on my /home and /var filesystems on my inux enterprise edition mail server where my 12000 users mailboxes (having Uids > 99) reside in /var/mail....What i need is a shell script which wud automatically calculates the users which exceeds the disk limit tht i have allocated to them and send them email autonatically warning them to stay with in limits and how much space they have consumed out of how much they have permission to use .
I m pasting below the script tht i've got but it takes ages and it stays there running but doing nuthing or may b it hangs i dunt know.please someone check this script or someone has a better script do send me .

# DISKHOGS - Disk quota analysis tool for Unix, assumes all user
# accounts are >= UID 100. Emails message to each violating user
# and reports a summary to the screen


trap "/bin/rm -f $violators" 0

for name in $(cut -d: -f1,3 /etc/passwd | awk -F: '$2 > 99 { print $1 }')
echo -n "$name "

find / /usr /var /Users -user $name -xdev -type f -ls | \
awk '{ sum += $7 } END { print sum / (1024*1024) }'

done | awk "\$2 > $MAXDISKUSAGE { print \$0 }" > $violators

if [ ! -s $violators ] ; then
echo "No users exceed the disk quota of ${MAXDISKUSAGE}MB"
cat $violators
exit 0

while read account usage ; do

cat << EOF | fmt | mail -s "Warning: $account Exceeds Quota" $account
Your disk usage is ${usage}MB but you have only been allocated
${MAXDISKUSAGE}MB. This means that either you need to delete some of
your files, compress your files (see 'gzip' or 'bzip2' for powerful and
easy-to-use compression programs), or talk with us about increasing
your disk allocation.

Thanks for your cooperation on this matter.

Dave Taylor @ x554

echo "Account $account has $usage MB of disk space. User notified."

done < $violators

exit 0
thnx for the help in advance
  • gavin
  • Born
  • Born
  • gavin
  • Posts: 1

Post 3+ Months Ago

I am looking around the net for a script that would check user quotas and
send an email when the user is close to full. I would also like to deny the prosess
when an account is full. I have around 300 domains on my mail server.

Thank you.

Its postfix if that helps.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 14 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.