Frugal install: rotating logs?


Forum: HD Install
Topic: Frugal install: rotating logs?
started by: gjhicks

Posted by gjhicks on May 21 2006,10:57
Hi,

Am using a frugal install of DSL to run a server.

It is also a samba and vnc server.

The system works just fine but over time (say, 5-10 days) it grinds to a halt.

It seems that the various logs grow to huge sizes.

Most of the 'googled' approaches refer to 'logrotate' but this utility isn't available in DSL.  When I tried to 'apt-get' it, I got lots of nasty looking dependency errors.

Any suggestions gratefully received,

Geoff.

Posted by mikshaw on May 21 2006,15:03
You could script the rotation from /opt/bootlocal.sh at bootup, or /opt/powerdown.sh to do it at shutdown.  Essentially you'd check the size of each log file, and if it reaches a given size you'd rename it. Something like this, maybe....
Code Sample
LOG_LIMIT=100000 #approx 100k
for i in  /var/log/{logfile1,logfile2,etc}; do
LOG_SIZE=`ls -l $i | awk '{print $5}'`
if [ $LOG_SIZE -gt $LOG_LIMIT ]; then
OLD="$i.`date +%F`"
mv $i $OLD
touch $i
fi
done


NOTICE: this is untested!

Posted by gjhicks on May 23 2006,03:28
Hi,

Thanks for the suggestion.

As I mentioned, the DSL box is being used as a server, so (hopefully!) the bootlocal.sh and powerdown.sh are only very rarely used!

Will have go using crontab to run the script.

Thanks again,

Geoff.

Posted by gjhicks on May 29 2006,12:13
Hi,

Spent a bit of time getting 'cron' to work with a frugal install, posted a little 'howto' in the 'tips & tricks' forum, called "How to set up 'cron' for a frugal install".

Thanks again for your suggestions and help.

Geoff.

Posted by mikshaw on May 29 2006,13:53
This is a bit late, but you can set up a script to run at specified intervals using sleep:
Code Sample
while true; do scriptname && sleep 6h || break; done

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.