Skip to Content.
Sympa Menu

en - Re: [sympa-users] Sympa log file handling?

Subject: The mailing list for listmasters using Sympa

List archive

Chronological Thread  
  • From: Sean Hennessee <address@concealed>
  • To: Steve Shipway <address@concealed>, "address@concealed" <address@concealed>
  • Subject: Re: [sympa-users] Sympa log file handling?
  • Date: Wed, 9 Oct 2013 20:59:47 +0000

Thanks for your help Steve.

I tried manually restarting Sympa with the stop/sleep/start commands you
suggested, but Sympa is still writing to the old log file.

I just updated my logrotate.d/sympa file to this:
/var/log/sympa.log {
daily
missingok
ifempty
copytruncate
dateext
dateformat %Y%m%d.
create 640 sympa sympa
postrotate
/etc/init.d/sympa stop
sleep 30
/etc/init.d/sympa start
endscript
}

and manually ran logrotate:
logrotate /etc/logrotate.conf
and manually restarted Sympa again:
service sympa stop
service sympa start
but it did not change anything to do with the logs, (and gave no errors);
sympa is still writing to the old log file.
[root]# ll /var/log/sympa.log*
-rw-r----- 1 sympa sympa 0 Oct 9 10:48 /var/log/sympa.log
-rw-r----- 1 sympa sympa 57M Jun 20 10:52 /var/log/sympa.log-20130620
-rw-r----- 1 sympa sympa 509M Aug 19 08:18 /var/log/sympa.log-20130624
-rw-r----- 1 sympa sympa 50M Oct 3 06:36 /var/log/sympa.log-20130820
-rw-r----- 1 sympa sympa 84M Oct 9 13:47 /var/log/sympa.log-20131004


This is very confusing. I have a pretty good understanding of Redhat and
basic linux ideas, but none of this is making any sense. I even checked the
log file, "tailf sympa.log-20131004", to make sure it was actually still
writing to that specific file, and it was/is. I'm thinking about rebooting
the server and seeing if that gets it to start a new log file, but that is
not a good solution for a daily 'kick'.

Peace,
Sean
--
Sean Hennessee
Enterprise & Unix Services
Office of Information Technology
UC Irvine


On Oct 9, 2013, at 12:29 PM, Steve Shipway <address@concealed> wrote:

Using logrotate on sympa log files.

The problem here is that logrotate normally works by renaming the old file
and creating a new one. However, if the application (sympa, in this case)
does a single open of a file descriptor for the logging file, then this FD
will continue to point to the old file, until (for some reason) it does a
reopen. Hence, the new file has length 0 and the oldfile continues to grow.

To get around this, logrotate has a couple of options. Firstly, it can
perform actions after the rotate - such as sending a SIGHUP to the relevant
daemon, so that it knows it is time to re-open the log files. This method is
used for many daemons; if you have a PID file for sympa, then you can add a
post rotate script to do a "kill -HUP `cat $pidfile`".

Unfortunately, not all applications will catch SIGHUP and trigger a log file
re-opening. In particular, sympa uses SIGHUP to indicate a request to stop
detailed logging so this is no use.

What you can do, is to have a postrotate action of "/etc/init.d/sympa
restart". However this can be problematic with a large list server, which
takes longer to shut down the sympa.pl process, so you might instead like to
do this:

postrotate
/etc/init.d/sympa stop
sleep 30
/etc/init.d/sympa start
endscript

You can adjust the sleep time for whatever works for you. Of course, your
list server is inactive during the rotate, but this is unlikely to be
problematic unless you have a seriously high throughput... (We use this
method).

The second option you have is using copytruncate. This makes logrotate copy
the log file and truncate the old one, instead of renaming and creating a new
one. This means that the sympa process can keep its FD open to the file
without having to restart. However, there is a small race condition that
means you may lose a log entry between the copy and the truncate actions;
also, there is a chance that for some reason the append doesnt combine with
the truncate correctly, so you should test it out first.

The best solution can only be done by the Sympa development team - have sympa
respond to a signal (SIGUSR1?) by re-opening its log files, allowing a smooth
transition by logrotate.

Steve

Steve Shipway
University of Auckland ITS
UNIX Systems Design Lead
address@concealed
Ph: +64 9 373 7599 ext 86487






Archive powered by MHonArc 2.6.19+.

Top of Page