[asterisk-users] Asterisk 1.2.10 - Continually Restarting Logger

Tzafrir Cohen tzafrir.cohen at xorcom.com
Sat Jul 29 20:27:45 MST 2006


On Fri, Jul 28, 2006 at 02:33:11PM +0100, Kenny Millington wrote:
> Koen Van Impe wrote:
> > I use logrotate too, because I didn't know of the functionality in Asterisk.
> > Logrotate works fine for me though.
> 
> Ok, I believe I see the problem here!
> 
> I was told (apparently erroneously) that asterisk does rotation itself
> because "they didn't rotate before and now they do".

It does, if so ordered from cron. Its log rotation is still not as
fully-features as logrotate, I believe. 

> 
> I've just looked in the /etc/logrotate.d/ directory and there's an
> asterisk file containing:-
> 
> # cat /etc/logrotate.d/asterisk
> # system-specific logs may be configured here
> 
> /var/log/asterisk/* {

Here's your problem: you're telling it to rotate
/var/log/asterisk/messages.1.gz etc. Quite funny actually, if it doesn't
happen on your system.

So you should:

A. edit this file to contain specific file names (or edit your
logger.conf config to have a suffing of .log to all the log files
there).

But even when you do that, next log rotates will take very long. If
you'll strace logrotate you'll then notice it tries to stat every file
it has rotated before.  This is because they are still listed in the
logrotate status file (/var/lib/logrotate/status on my system)

B. Edit the logrotate status file and delete all entries of bogus log
files. Probably something like: 

  sed -i -e '/\/var\/log\/asterisk/d' /var/lib/logrotate/status

(But the above is untested)

>   daily
>   postrotate
>   /usr/sbin/asterisk -rx "logger rotate"
>   endscript
> }
> 
> Now... If I were to guess I'd guess that the * is matching the logs that
> have already been rotated and rotating them, generating yet more files
> to be matched by the * and hence rotated... Does that sound plausible?

> 
> At any rate, I'm going to specify the files without using a wildcard
> match and see how that goes.

Hmm.. Just read this thread. This was my guess all along. This funny
thing happened to me before. Renaming the log files to *.log will also
simplify your logrotate file. Anyway, the Debian file has something of 
the sort of:

  /var/log/asterisk/cdr-csv/Master.csv /var/log/asterisk/debug /var/log/asterisk/event_log /var/log/asterisk/messages {

However here's something less obvious:

Even after you edit the logrotate config, next log rotates will take very 
long. If you'll strace logrotate you'll then notice it tries to stat 
every file it has rotated before.  This is because they are still listed 
in the logrotate status file (/var/lib/logrotate/status on my system)

Edit the logrotate status file and delete all entries of bogus log
files. Probably something like: 

  sed -i -e '/\/var\/log\/asterisk/d' /var/lib/logrotate/status

(But the above is untested)

-- 
Tzafrir Cohen         sip:tzafrir at local.xorcom.com
icq#16849755          iax:tzafrir at local.xorcom.com
+972-50-7952406          jabber:tzafrir at jabber.org
tzafrir.cohen at xorcom.com     http://www.xorcom.com



More information about the asterisk-users mailing list