Solved

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

Posted on 2011-02-23
3
581 Views
Last Modified: 2012-05-11
please provide me a simple bash script which will check the user quota, 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
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
Maciej S earned 500 total points
ID: 34968033
Name it for example: check_quota.sh, add +x permission, and run: check_quota.sh user_name (for example: check_quota.sh penn).
#!/bin/sh

USER=$1
LIMIT=250000

Q=`sudo -u ${USER} quota | tail -n1 | awk '{print $2}'`
if [ "${Q}" -gt "${LIMIT}" ]; then
   echo "User: ${USER}; quota exceeded" | mailx -s "quota exceeded" webadmin aa12erp aa13nbc
fi

Open in new window

0
 
LVL 23

Assisted Solution

by:Maciej S
Maciej S earned 500 total points
ID: 34968036
My mistake - replace print $2 with print $1
0
 

Author Closing Comment

by:wasman
ID: 34974516
Thanks a lot for helping me
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Utilizing an array to gracefully append to a list of EmailAddresses
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now