Solved

Check the user quota, if it excceds send email to user accounts

Posted on 2011-02-22
5
558 Views
Last Modified: 2012-05-11
please provide me a simple bash script which will check the user quote, if it exceeds more then 250mb, then it will trigger an email to user accounts --> webadmin, aa12erp and aa13nbc

$ sudo -u penn quota
Disk quotas for user penn (uid 1001734):
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
/dev/01
                  45800  200000 3000000              25       0       0


]$ uname -a
Linux test012.6.9-89.0.23. #1 SMP Fri Mar 5 18:01:22 EST 2010 i686 i686 i386 GNU/Linux


i am going to setup a cronjob to excute this shell script every one hour
0
Comment
Question by:wasman
  • 3
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 500 total points
ID: 34958542
you can always do

q=`sudo -u penn quota | tail -1 | cut -f 3`
s=`expr $q / 2048`

then you can compare $s if greater than 250
0
 

Author Comment

by:wasman
ID: 34961667
$ q=`sudo -u loslsr quota | tail -1 | cut -f 3`
$ echo $q
48716 200000 3000000 26 0 0
$ s=`expr $q / 2048`
expr: syntax error
Please help
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 34964504
from your quota command output the 3rd field is 300000 and cut should have returned that number

I do not know why it is returning the whole line
0
 

Author Comment

by:wasman
ID: 34965234
my OS is
$ cat /etc/*release
Red Hat Enterprise Linux AS release 4 (Nahant Update 7)
0
 

Author Closing Comment

by:wasman
ID: 34974565
Thanks for trying
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question