NSLU2-Linux
view · edit · print · history

Optware.Logrotate History

Hide minor edits - Show changes to markup

March 27, 2008, at 09:37 PM by tlhackque -- Update on interaction with syslog-ng
Added lines 60-62:

syslog-ng has problems with logrotate prior to syslog-ng 2.0.9 and glib 2.2.12. Any kill or termination of syslog-ng can cause it to become very confused. At this writing, the new syslog is in the ipkg feed - so upgrade! The new glib has been requested.

March 14, 2008, at 07:24 PM by tlhackque --
Changed lines 33-34 from:
        tabooext .disabled
to:
        tabooext + .disabled
March 14, 2008, at 07:00 PM by tlhackque -- Corrections and clarifications
Added lines 10-11:

>> This isn't correct. "include /opt/etc/cron.d" tells logrotate to merge all the configuration files in that directory - and if you test it, it does.

Changed line 16 from:
        /opt/var/log/router opt/var/log/syslog {
to:
        /opt/var/log/router /opt/var/log/syslog {
Added lines 27-62:

>> Actually, no. include means to include the specified file (in this case, all the files in the directory /opt/etc/logrotate.d except *.{rpmorig,rpmsave,',v',.swp,.rpm-new & ~}) at this point in the config file. This allows another package's install script to just drop a file with it's requirements into /opt/etc/logrotate.d instead of editing the main config file. Also, you were missing a / in /opt/ar/log/syslog, and as Julius notes below, you really want sharedscripts.

A slightly better setup would be:

  /opt/etc/logrotate.conf
        compress
        tabooext .disabled

        include /opt/etc/logrotate.d

  /opt/etc/logrotate.d/syslog-ng.conf
        /opt/var/log/router opt/var/log/messages {
                   rotate 5
                   sharedscripts
                   delaycompress
                   postrotate
                            /bin/killall -HUP syslog-ng
                   endscript
                   }

  /opt/etc/logrotate.d/syslog.conf.disabled
        /var/log/messages {
                   rotate 5
                   delaycompress
                   postrotate
                            /bin/killall syslogd
                            /bin/killall klogd
                   endscript
                  }

The .disabled extension makes it easy to switch logrotate from syslog to syslog-ng. delaycompress is because syslsog won't release the log file until the postrotate script runs, but compression runs before that. There doesn't seem to be a quicker race-free way to make this work. (firstaction/lastaction also seem to come a the wrong time)

Of course, any other package install just adds its snippet to logrotate.d. And uninstall removes it.

  --tlhackque
February 03, 2007, at 08:47 PM by Julius -- Minor editorial change
Changed line 52 from:
sharedscripts
since I use a wildcard to logrotate all logfile in one directory together I want the postrotate script to run only once
to:
sharedscripts
Since I use a wildcard to logrotate all logfiles of the logging-directory, I want the postrotate script (restarting the system logger) to run only once
February 03, 2007, at 08:44 PM by Julius -- Better layout
Changed lines 51-54 from:

nocompress - I do not need compression sharedscripts - since I use a wildcard to logrotate all logfile in one directory together I want the postrotate script to run only once olddir - I put all my old loggings in a subdirectory 'oldlog'. Please note to create this directory before runnig logrotate

to:
nocompress
I do not need compression
sharedscripts
since I use a wildcard to logrotate all logfile in one directory together I want the postrotate script to run only once
olddir
I put all my old loggings in a subdirectory 'oldlog'. Please note to create this directory before runnig logrotate
February 03, 2007, at 08:36 PM by Julius -- Alternative example
Added lines 34-62:

===

For me the better option is the following /opt/etc/logrotate.conf file:

         nocompress
         sharedscripts
         olddir oldlog

         /opt/var/log/* {
                 rotate 5
                 size 100k
                 postrotate
                         /opt/etc/init.d/S01syslog-ng
                 endscript
         }

nocompress - I do not need compression sharedscripts - since I use a wildcard to logrotate all logfile in one directory together I want the postrotate script to run only once olddir - I put all my old loggings in a subdirectory 'oldlog'. Please note to create this directory before runnig logrotate

I used the following line in the /opt/etc/crontab file

         15 0 * * * root /opt/sbin/logrotate /opt/etc/logrotate.conf &>/dev/null

The logrotate script will be run every night at 00:15.

Julius

===

January 19, 2007, at 11:40 AM by fcarolo -- added wiki links
Changed lines 3-4 from:

With much help and support from the mailing list, I have configured syslog-ng to receive log messages from both my adsl/voip router and from the slug itself. After some time, these logs get quite large in size so I examined a way to compress/rotate the logs. Logrotate is an optware package. To install...

to:

With much help and support from the mailing list, I have configured syslog-ng to receive log messages from both my adsl/voip router and from the slug itself. After some time, these logs get quite large in size so I examined a way to compress/rotate the logs. Logrotate is an Optware package. To install...

January 18, 2007, at 08:38 PM by Humpda --
Changed lines 29-30 from:

In this case, this runs this cron job every hour on the hour. I used this setting initially to check if it worked Ok. This created the files in my opt/var/log called router.1.gz, router.2.gz etc etc. I then modified the time/date settings to meet my specific requirements.

to:

In this case, this runs this cron job every hour on the hour. I used this setting initially to check if it worked Ok. This created the files in my opt/var/log called router.1.gz, router.2.gz etc etc. Notice the "rotate 5" comment. Change this number to reflect how many versions of the logs you wish to keep. Once it reaches 5, it will begin to overwrite the existing logs. I then modified the time/date settings to meet my specific requirements.

Deleted lines 33-39:
January 18, 2007, at 08:35 PM by Humpda --
Changed lines 1-2 from:

Using Logrotate with Syslog-ng (Unslung 6.8)

to:

Using Logrotate with Syslog-ng (Unslung 6.8)

January 17, 2007, at 10:17 PM by Humpda --
Changed lines 5-6 from:
  1. ipkg install logrotate
to:
        ipkg update
        ipkg install logrotate
January 17, 2007, at 10:16 PM by Humpda --
Changed lines 24-25 from:

I then needed to set up a cron job for this to run. I am new to the slug so am not sure if this is the correct way and I ams ure there are other/better ways. I simply opened up the file crontab in the /etc directory and added the following line into the cron jobs..

to:

I then needed to set up a cron job for this to run. I am new to the slug so am not sure if this is the correct way and I am sure there are other/better ways. I simply opened up the file crontab in the /etc directory and added the following line into the cron jobs..

Changed lines 28-29 from:

In this case, this runs this cron job every hour on the hour. I used this setting initially to check if it worked Ok. This created the files in my opt/var/log called router.1.gz, router.2.gz etc etc

to:

In this case, this runs this cron job every hour on the hour. I used this setting initially to check if it worked Ok. This created the files in my opt/var/log called router.1.gz, router.2.gz etc etc. I then modified the time/date settings to meet my specific requirements.

January 17, 2007, at 10:13 PM by Humpda --
Changed lines 24-25 from:

I then needed to set up a cron job for this to run. I am new to the slug so am not sure if this is the correct way. I simply opened up the file crontab in the /etc directory and added the following line into the cron jobs..

to:

I then needed to set up a cron job for this to run. I am new to the slug so am not sure if this is the correct way and I ams ure there are other/better ways. I simply opened up the file crontab in the /etc directory and added the following line into the cron jobs..

Changed lines 28-29 from:

In this case, this runs this cron job every hour on the hour. I used this setting initially to check if it worked Ok. This created a files in my opt/var/log called router.1.gz, router.2.gz etc etc

to:

In this case, this runs this cron job every hour on the hour. I used this setting initially to check if it worked Ok. This created the files in my opt/var/log called router.1.gz, router.2.gz etc etc

Changed lines 32-36 from:
to:

Cheers

January 17, 2007, at 10:11 PM by Humpda -- Added Unslung reference to title
Changed lines 1-2 from:

Using Logrotate with Syslog-ng

to:

Using Logrotate with Syslog-ng (Unslung 6.8)

January 17, 2007, at 10:07 PM by Humpda -- Created logrotate info in Optware packages
Added lines 1-39:

Using Logrotate with Syslog-ng

With much help and support from the mailing list, I have configured syslog-ng to receive log messages from both my adsl/voip router and from the slug itself. After some time, these logs get quite large in size so I examined a way to compress/rotate the logs. Logrotate is an optware package. To install...

  1. ipkg install logrotate

This creates a number of files. In /opt/etc there is logrotate.conf and logrotate.d, while in /opt/sbin you will find the logrotate program. The install also adds a file in /opt/etc/cron.d, however I have been informed by the NSLU2 list that slugs using Unslung (I am using 6.8 beta) do not reference/read the cron.d file.

I needed to edit the logrotate.conf file to to make it work with syslog-ng. Again a big thanks to the NSLU2 forum for their assistance with this. My working logrotate.conf file is below (I used nano to edit). The /opt/var/log directory contains the logs created by syslog-ng...in my case called syslog and router. You will need to change these to reflect your log names/paths.

        compress

        /opt/var/log/router opt/var/log/syslog {
                   rotate 5
                   postrotate
                            /bin/killall -HUP syslog-ng
                   endscript
                   }

        include /opt/etc/logrotate.d

I believe that logrotate is supposed to move the compressed files to opt/etc/logrotate.d but this does not occur for me so I guess their is an error with the last line. However the program works fine without this so I did not tinker :)

I then needed to set up a cron job for this to run. I am new to the slug so am not sure if this is the correct way. I simply opened up the file crontab in the /etc directory and added the following line into the cron jobs..

         0 * * * * root /opt/sbin/logrotate -f /opt/etc/logrotate.conf &>/dev/null

In this case, this runs this cron job every hour on the hour. I used this setting initially to check if it worked Ok. This created a files in my opt/var/log called router.1.gz, router.2.gz etc etc

As I mentioned this is not my own work, but rather a product of the assistance given to me by the NSLU2 forums (Thanks Fernando, Mike, Rod and Ovidiu Sas). I hope this can assist others.

view · edit · print · history · Last edited by tlhackque.
Based on work by tlhackque, Julius, fcarolo, and Humpda.
Originally by Humpda.
Page last modified on March 27, 2008, at 09:37 PM