NSLU2-Linux
view · edit · print · history

Here is a very simple script that I use to save incrementally the message logs for UnSlung? 6.10. It is simple and very quick to set up instead of using log rotate. I hope someone will find this useful, I have.

simplified log rotate for unslung

1.) create file /opt/etc/init.d/S92msglogbk (or similar) with contents:

#!/bin/sh
 if [ -n "`pidof msglogbk`" ]; then
    /bin/killall msglogbk 2>/dev/null
 fi
 umask 077
 /opt/bin/msglogbk

2.) create file /opt/bin/msglogbk with contents:

#!/bin/ash
if [ -f /var/log/messages.0 ]
then
   dtxx=`date +%Y%m%d.%H%M%S`
   mv /var/log/messages.0 /var/log/messages.$dtxx
   gzip /var/log/messages.$dtxx
fi
# created by SRS

3.) edit your /etc/crontab file to add a line like:

*/5 * * * * root /opt/bin/msglogbk &>/dev/null

for unslung 6.8 or earlier you should reduce the 5 minutes to 1 minute as the log files are much smaller and therefore fill much faster than in unslung 6.10

set the S92msglogbk, msglogbk and crontab permissions to read and Xexecute and your logs will be compressed and saved by date-time names.

Enjoy!

view · edit · print · history · Last edited by SRS.
Originally by SRS.
Page last modified on December 26, 2012, at 08:51 PM