--- In [email protected], "senty_dil" <arpittol...@...> wrote:
>
> i have a fresh partition /dev/sda4 of 4 GB for cache and it is mounted
> on /cache.
>
> now i want to make a automated script which cleans the cache after it
> reaches 90%...
>
> i am complete newbie in scripting and awk..
>
>
> what i got after studing is this
> df -h | grep /dev/sda4 | awk '/dev/sda4 { print $6 "\t: " $5}'
>
> so that it will tell me /cache is how much full..
>
> now please help me to move further....
>
> or send me the script if you have one.
>
> thanks.....
>
#!/bin/bash
# Shell script to monitor or watch the disk space
# -------------------------------------------------------------------------
# set alert level (85% is default)
ALERT=85
df -H | grep /dev/sda4 | awk '{ print $5 " " $1 }' | while read output;
do
echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
if [ $usep -ge $ALERT ]; then
/etc/init.d/dansguardian stop
/etc/init.d/squid stop
rm -rvf /cache/*
squid -z
/etc/init.d/squid start
/etc/init.d/dansguardian start
fi
done