Solved

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

Posted on 2011-02-23
3
589 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

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…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
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 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 …

756 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