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, Regards, Pralay |
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?
|
i done something like this
hello,
#!/bin/bash DIR=/home/pralay 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. Regards, Pralay |
Youll have to put in your own host name and $limit.
------------------------------------------------------- #!/usr/bin/perl # #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]\@yourhost.com"); } } ---------------------------------------------- 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 11:22 PM. |