[syslog-ng] Logrotate Not Rotating All - Need Help Matching Rules (Possible Solution)

wiskbroom at hotmail.com wiskbroom at hotmail.com
Thu May 8 15:48:57 CEST 2008


Thanks!I *think* I have a solution:1.  Created a script named make-new-config.sh (see below make-new-config.sh)2.  I created a file which will be appended to the dynamically generated one (see  logrotate-append.txt below)3.  I've added make-new-config.sh to /etc/cron.daily/logrotate on the line directly above /usr/sbin/logrotate /etc/logrotate.conf.What it does?  Basically re-generate a new config for logrotate based on what is contained in /var/log/MyHosts/ with more than zero byte size.Any suggestions would be greatly appreciated..vp### make-new-config.sh ####!/bin/sh#  This for recordkeeping/troubleshooting, until the next run that is.find /var/log/MyHosts/ -name "*.log" -empty -exec ls -al {} \; > /var/log/MyHosts/Deleted-Empty-Logs#  This one to remove unwanted files, presumably from hosts no longer existent?find /var/log/MyHosts/ -name "*.log" -empty -exec rm {} \;#  Generate list of valid/current logsfind /var/log/MyHosts/ -name "*.log" -print > /var/log/MyHosts/Latest-Logs-Prepend#  Begin creating a new syslog-ng in logrotate.decho "#" > /etc/logrotate.d/syslog-ngecho "# DO NOT EDIT THIS FILE MANUALLY - SEE CRONJOB WHICH CREATED IT INSTEAD" >> /etc/logrotate.d/syslog-ngecho "#" >> /etc/logrotate.d/syslog-ng#  Append two files together, making one final /etc/logrotate.d/syslog-ng.# The logrotate-append.txt is shown below.cat /var/log/MyHosts/Latest-Logs-Prepend /etc/syslog-ng/logrotate-append.txt >> /etc/logrotate.d/syslog-ng###  logrotate-append.txt ##### DO NOT EDIT THIS FILE - IT IS AUTOMATICALLY CREATED VIA SCRIPT IN CRON## The non-MyHosts nodes will be placed below this line.# Basically, anything that does *NOT* live under /var/log/MyHosts//var/log/messages/var/log/secure/var/log/maillog/var/log/spooler/var/log/boot.log/var/log/cron {        missingok        weekly        rotate 4        create        compress        copytruncate        ifempty#    olddir /var/log/MyHosts/Archived-Logs/        sharedscripts        postrotate        sharedscripts        postrotate                n/kill -HUP `cat /var/run/syslog-ng.pid 2> /dev/null` 2> /dev/null || true        endscript}# END OF FILE> Date: Wed, 7 May 2008 13:00:05 +0100> From: hpsekhon at googlemail.com> To: syslog-ng at lists.balabit.hu> Subject: Re: [syslog-ng] Logrotate Not Rotating All - Need Help Matching	Rules> > Quick workaround:> > Write a bash script to generate your logrotate files just before your > logrotate is called by looking at what files exist. This will then > logrotate all your dynamic files that exist at the time. You might want > to have this script delete the logrotate configs for files which no > longer exist as well if using one config per file... although I think it > would be easier to have one big auto-generated config for all those > dynamic files and have it replaced by the script once a day just before > logrotate is run...> > -h> > -- > Hari Sekhon> > > wiskbroom at hotmail.com wrote:> >> >     My logrotate.d/syslog-ng file contains a few entries for many> >     different logs, see below.> >> >     My syslog-ng.conf automatically creates entries for many different> >     hosts, each with unique hostnames, depending on their purpose. > >     The "purpose" for the hosts each have a different subdir under> >     /var/log/Myhosts/, i.e. /var/log/Myhosts/Switches and> >     /var/log/Myhosts/Firewalls.> >> >     Logrotate does not work unless I've added each host separately> >     under my logrotate conf, which is impossible since I dynamically> >     create these entries via mysyslog-ng.conf .> >> >     Any help greatly appreciated.> >> >     .vp


More information about the syslog-ng mailing list