Solved

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

Posted on 2011-02-23
3
590 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

738 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