Results 1 to 5 of 5
Hi All,
I wrote a small script, which finds the size of "/" and "/var" FS, if it exceeds 80% it should alert me. The below is my script.
hname=`hostname`
...
- 04-06-2011 #1Just Joined!
- Join Date
- Mar 2009
- Posts
- 13
Bash Scritping
Hi All,
I wrote a small script, which finds the size of "/" and "/var" FS, if it exceeds 80% it should alert me. The below is my script.
hname=`hostname`
FS="/ /var"
Size="80"
for i in ${FS[@]}
do
Disk_Free=`df -h $i | tail -n 1 | awk '{ print $4 }'`
if [ $Disk_Free -ge $Size ]
then
echo "$i" needs attention in "$hname"
else
echo "$i" is OK in "$hname"
fi
done
The problem I am facing is i dont know how to remove the % symbol from df -h output, because of this my script is not working properly. Any help will be appreciated.
If for example output of the below command is 85%, I want to remove the % symbol from this output in a single command
Disk_Free=`df -h $i | tail -n 1 | awk '{ print $4 }'`
Thanks
Puru
- 04-06-2011 #2
Hi Puru,
Try:
Disk_Free=`df -h $i | tail -n 1 | sed 's/%//' | awk '{ print $4 }'`
- 04-07-2011 #3Just Joined!
- Join Date
- Mar 2009
- Posts
- 13
- 04-07-2011 #4
- 04-07-2011 #5Just Joined!
- Join Date
- Apr 2011
- Posts
- 1
I am doing an assignment for my linux class and this is very similar to what I am doing, but not only do i need to be alerted about a filesystem becoming full, but i need a beep command that would beep along with an alert message. Anyone knows how to add a beep command on a script? I've been checking through various sites and none seems to work so far.


Reply With Quote
