Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
Site Navigation
Linux Forums
Linux Articles
Product Showcase
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Free Publications


This shell script checks the Mailbox size of user and if it is greater than the threshold limit, it will send a mail to user and System Admin for the further action. This may cron and may be generalized for all the users

#!/bin/bash
#Script checks the Mailbox size of user and if it is greater than the threshold limit, it will send a mail to user and Admin. This may be cron.

#THRESHOLD is 1228800KB=1200MB


THRESHOLD=1228800

#awk print first column value, sed remove M from the output i.e. if it is 300M then it will display only 300. But some time size will be in GB so it will not work. Better display in default unit i.e. KB by removing -h (human). Now KB will not be displayed explicitly


#CURRENT=$(du -hs /home/USERID/Mailbox | awk '{print $1}' | sed 's/M//g')


CURRENT=$(du -s /home/USERID/Mailbox | awk '{print $1}')


let S=($CURRENT)/1024




#in echo -e option is used to enable n (newline) otherwise it will just display n rather than new line.


[ $CURRENT -gt $THRESHOLD ] &&  echo -e "Your Mailbox is reached Threshold limit i.e. $THRESHOLD MB. Current size is $S MB.

n Contact it@urdip.res.in for the required action soon. n Dont Reply to this mail, it is an automated mail. nn Regards,

n IT Team" | mail -s "MailBox Size[Urgent]" userid@somedomain.com,sysadmin@somedomain.com


 
Rate This Article: poor excellent
 
Comments about this article
Mistake while displaying "\n" in the script.
writen by: alokkhode on 2009-12-08 05:27:00
n should be read as \n at the last three lines
RE: Mistake while displaying "\n" in the script. written by alokkhode:
Mistake while displaying "\n" in the script.
writen by: alokkhode on 2009-12-08 05:27:05
n should be read as \n at the last three lines
RE: Mistake while displaying "\n" in the script. written by alokkhode:

Comment title: * please do not put your response text here