How to write this script?
I want to write script so that is "/var" partition exceeds 90% then it should mail to me.
Please give me guidelines.
Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!
How to write this script?
I want to write script so that is "/var" partition exceeds 90% then it should mail to me.
Please give me guidelines.
Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!
Here is one way of doing it:
#!/usr/bin/ksh
typeset -i mPct=$(df -k /var | sed -n '/%/s/%.*//p')
if [[ ${mPct} -ge 90 ]]; then
<insert your mail statement here>
fi
Hi,
You can use the following code also.
#!/bin/ksh
FS=`/usr/sbin/df -k /var | /usr/bin/tail -1 | /usr/bin/awk '{print $5}' | cut -d % -f1`
if [ $FS -gt 90 ]
then
mailx -s "Filesystem /var over 90% " name@domain.com
fi
Schedule it in crontab to execute every 3 mins or as required.
Thanks guys you are very helpful, Will try this!