?
Solved

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

Posted on 2011-02-23
3
Medium Priority
?
593 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 2000 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 2000 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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

718 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