-   Linux - Networking (
-   -   script for checking disk space (

pralaydesai 03-24-2003 08:59 AM

script for checking disk space
Hello All,

I want write a script that checks space of directories on linux server and if space is more the limit then send mail to perticular user.

Can any one help me in this regards?

Thanks in advance,


unSpawn 03-24-2003 10:06 AM

Sure we can help, but could you post any leads on what you've done so far, or are we supposed to write it from scratch ourselves?

pralaydesai 03-25-2003 12:34 AM

i done something like this

masg="you are occuping"
cd $DIR
du -s -h $DIR | sort -rn >spa
mail pralay -s "Your space Utilization" <spa

now i want that to append the whatever in masg variable has to append in massage body after space is coming from spa.

One more thing is that i also want it for all users.


m0rl0ck 03-25-2003 03:34 AM

Youll have to put in your own host name and $limit.

#limit is space in bytes adjust it as necessary
$limit=2000000; # about 2 gigs

$howmuch=`cd /home;ls|xargs du -s`;

@lusers=split "\n",$howmuch;

foreach $luser (@lusers){
@luserspace=split " ",$luser;
if (@luserspace[0]>$limit){

system ("echo 'Get your space below $limit or your data is forfiet'|mail -s \"YOU A BIG FAT PIG\" @luserspace[1]\");


I am truly sorry about this. I get started and before I know whats happended I've commited an atrocity.

All times are GMT -5. The time now is 02:33 PM.