1828586 Members
2497 Online
109982 Solutions
New Discussion

Scripts

 
logaraman
Regular Advisor

Scripts

Hi ,

I have a linux server from where I need to run a script on the disk space availability which should create a file and that file has to be sent to my outlook inbox( my mailing system is Exchange) .

Any suggestions on this please or any scripts on this please
3 REPLIES 3
TANHM
Advisor

Re: Scripts

Hi,

Did u mean u want a script to check the file system disk usage?

The below is a simple example :

if [ $OSTYPE = "Linux" ]; then
/bin/df -kl|grep -vi used|grep %|sed 's/\%//' > /tmp/disk.txt

awk '{if($5 > 90) print $5, $6}' /tmp/disk.txt > /tmp/alert.txt

/bin/mail -i -s "File system/s on $HOSTNAME is/are almost full @ $Date!! Please check!" your email address < /tmp/alert.txt

Provided your linux are able to send out mail.

Thanks & Best Regards
HM
Ajay Agarwal
Frequent Advisor

Re: Scripts

Hi,

You can use mailx in your script to mail the file to any email id. You should add the following in your script after creating the file:

/bin/mail/mailx -s "subject... " your-email-id@xyz.com < /file/to/be/mailed

Vitaly Karasik_1
Honored Contributor

Re: Scripts

There is diskcheck package (http://linux.maruhn.com/sec/diskcheck.html), which was into RHL/Fedora.
For some reason the latest RHEL/Fedora don't have it, but you can use diskcheck for reference anyway.