"Administrator - Henry Smith Jr. " wrote:
I saw some mention before of Disk Quota Checking and after
reviewing it and attempting to implement the partial recipes, I
failed!
I have several users who constantly exceed their given 6Mb quota
(with email alone!). I would like to setup a recipe each users dir
that
would check the Disk Usage against their quota and if the incoming
email
Personnally, I used to use my mail space to get
around the disk quota limitation when I was in
university. I'd zip stuff and email it to myself
when I needed to empty my account to compile
code. (That and I'd use /usr/tmp and /tmp).
The following will show you how to calculate how
much their mail spool is taking & how much their
home directory is taking. (Note you might want to
check out /tmp as well). The end result is how
much space is left.
Put in FILEX limit in Megabytes with a minus sign
6 -
#Copy FILEX to FILEA
cp FILEX FILEA
# space taken by mail in megs
wc -c /var/mail/user | sed 's/$/\/ 1024/g' | bc >> f1
# now f1 contains the amount of megs of mail
# space taken by home dir in megs note a block
# on many unix boxes is = 512 bytes.
# So 2048 blocks = 1 meg
du -s /home/user/. | cut -f1 -d\[TAB] | sed 's/$/\/2048/g' | bc >> f1
# f1 now contains: mailsize space acctsize line feed
#change new lines for plusses
tr '\012' '+' < f1 > f2
# Add newline chars at the end
echo >> f2
#f2 now contains mailsize + acctsize linefeed
bc < f2 >> FILEA
#FILEA contains limit minus sum of mailsize + acctsize
#substract from the limit the amount:
tr '\012' ' ' < FILEA > f2
# It is neccessary to have a LF at the end
echo >> f2
#calculate how many megs of space is left
bc < f2 > SPACE.LEFT
Space left should contain the amount of megabytes
left. If it starts by a minus you're over your quota.
Note I just wrote these on the fly. (But I think they
will work as is).
You can use this in the BEGIN section of a AWK
script.
(I know I use AWK a lot but my c's rusty)
Jacques G.
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com