Find the answer to your Linux question:
Results 1 to 5 of 5
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Disk Quota shell script

    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.

    Shahzad @ x554

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

    done < $violators

    exit 0
    thnx for the help in advance

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    St. Petersburg, FL
    You might want to look into the program called "quota" which pretty much does the footwork for you.

  3. #3


    already implemented quota on the server , i just need a script which wud send an automatic email notification to the violating user when they exceed their disk quota limit.

  4. $spacer_open
  5. #4
    Normally, the process that violates the quota gets an error message.
    Most of the time users know they have gone over quota when it happens.

    Depending on the space you've allowed between quota and limit, they may hit the limit and be unable to work anyway. Sending email is not going to help.

    Send one email to everybody explaining what the quota is, and how it works.

  6. #5
    When they hit their softlimit of allowed quota mails will still dropped to their mail boxes and they'll b able to read and send mails ,i want tht script to send an automatically generated mail notificaion warning them about quoat violation .And when there hard limit will b hit only then mail account will b locked automatically...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts