1846867 Members
3210 Online
110256 Solutions
New Discussion

Re: Disk Fill up

 
James I
Occasional Contributor

Disk Fill up

A disk fills up regularly on my system. When the disk is full a necessary process called file4 dies.The disk that fills up it /var.I need a shell script that checks the disk to see if it's full, if it is, it prunes the logfiles causing the problem in /var/log/logfile and also checks to see if the file4 process is running and if it isn't restarts it by executing /etc/init.d/file4 start


3 REPLIES 3
Steven E. Protter
Exalted Contributor

Re: Disk Fill up

bdf | awk '{ if ($5 ~ /[8-9][0-9]/ || $5 ~ /[1][0-5][0-9]/) print }' >> $drep

rep=$(cat $drep | wc -l)


if [ $rep -ge 1 ]
mess=$(bdf /var | grep var | awk '{print $5}')
echo $mess
/usr/contrib/bin/trimlogs
else
echo no problems
fi




###
trimlogs


while read -r rfile
do
> $rfile
done < /var/filelist

/var/filelist is a list of log files with full path of files that you want to trim in an emergency.

I suggest you look in /var and build the list

Here are some suggestions

/var/adm/syslog/syslog.log
/var/mail/root

Take a look at sam routine tasks trim log files for more suggestions.

be careful, once this data is gone its done. No recycle bin.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
MarkSyder
Honored Contributor

Re: Disk Fill up

Have you thought of putting /var/log in its own logical volume so it doesn't affect /var?

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
James I
Occasional Contributor

Re: Disk Fill up

The solutions posted to me have not answered the question satisfactorily.I mean the script should be able to run on bash.