[prog] bash scipt question

Conor Daly conor.daly-linuxchix at cod.homelinux.org
Tue Jul 29 21:22:08 UTC 2008


On Tue, Jul 29, 2008 at 01:02:01AM -0700 or so it is rumoured hereabouts, 
Chris Henderson thought:
> 
> On Tue, Jul 29, 2008 at 12:29 AM, Tricia Bowen <tricia.bowen at gmail.com> wrote:
> > Hi Chris,
> > Can you provide some additional debugging information? Are you trying the -d
> > option for logrotate? Can you get the barebones of logrotate to work?
> 
> logrotate doesn't work as another process (snmp_collect) has already
> opened a file descriptor to the log file and writing to it. The only
> option is to (a) stop that other process (b) rotate the log, and (c)
> start the other process again.
> 
> I am just not sure how to go about doing that part.

You have two options available to you here.

1.  Prerotate:  Use a prerotate / endscript pair (like the postrotate
                 example below) to kill the logging process before the
                 rotate happens.  Then use a postrotate / endscript pair
                 to restart the logger process.

2.  Copytruncate:  From 'man logrotate':

copytruncate
      Truncate  the  original log file in place after creating a copy,
      instead of moving the old log file and optionally creating a new
      one,  It  can be used when some program can not be told to close
      its logfile and thus might continue writing (appending)  to the
      previous log file forever.  Note that there is a very small time
      slice between copying the file and truncating it, so  some
      logging  data  might be lost.  
 
> > Something in the logrotate config file like:
> >
> > "/home/snmp/logs/snmp.log" {
> >            rotate 5
> >            size=10k
> >            postrotate
> >                                      pkill snmp_collect
> >            endscript
> >        }

Conor
-- 
Conor Daly <conor.daly at cod.homelinux.org>
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/G/S/O d+(-) s:+ a+ C++(+) UL++++ US++ P>++ L+++>++++ E--- W++ !N
PS+ PE Y+ PGP? tv(-) b+++(+) G e+++(*) h-- r+++ z++++ 
------END GEEK CODE BLOCK------
http://www.geekcode.com/ http://www.ebb.org/ungeek/


More information about the Programming mailing list