Thread: Logrotate

Logrotate

From
Luis Sousa
Date:
Hi all,

I'm running postgresql 7.2.1 on a debian 3.0 machine and I want to do
some log rotation, but I'm having some problems. The configuration that
I'm using is:
In /etc/logrotate.d/postgres:
/var/log/postgres.log {
        weekly
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 postgres postgres
        sharedscripts
        postrotate
                /etc/init.d/postgresql restart > /dev/null
        endscript
}

But when this is executed, always is returned the following error:

pg_ctl: Another postmaster may be running.  Trying to start postmaster anyway.
pg_ctl: cannot start postmaster
Examine the log output.

Any sugestions !! What's wrong ?

Regards, Luis Sousa


Attachment

Re: Logrotate

From
Robert Treat
Date:
This is just a guess, but try changing your script to do reload instead
of restart.

Robert Treat

On Wed, 2002-11-20 at 05:14, Luis Sousa wrote:
> Hi all,
>
> I'm running postgresql 7.2.1 on a debian 3.0 machine and I want to do
> some log rotation, but I'm having some problems. The configuration that
> I'm using is:
> In /etc/logrotate.d/postgres:
> /var/log/postgres.log {
>         weekly
>         rotate 52
>         compress
>         delaycompress
>         notifempty
>         create 640 postgres postgres
>         sharedscripts
>         postrotate
>                 /etc/init.d/postgresql restart > /dev/null
>         endscript
> }
>
> But when this is executed, always is returned the following error:
>
> pg_ctl: Another postmaster may be running.  Trying to start postmaster
> anyway.
> pg_ctl: cannot start postmaster
> Examine the log output.
>
> Any sugestions !! What's wrong ?
>
> Regards, Luis Sousa
>




Re: Logrotate

From
Luis Sousa
Date:
Oliver Elphick wrote:

>On Wed, 2002-11-20 at 10:14, Luis Sousa wrote:
>
>
>>Hi all,
>>
>>I'm running postgresql 7.2.1 on a debian 3.0 machine and I want to do
>>some log rotation, but I'm having some problems. The configuration that
>>I'm using is:
>>In /etc/logrotate.d/postgres:
>>/var/log/postgres.log {
>>        weekly
>>        rotate 52
>>        compress
>>        delaycompress
>>        notifempty
>>        create 640 postgres postgres
>>        sharedscripts
>>        postrotate
>>                /etc/init.d/postgresql restart > /dev/null
>>        endscript
>>}
>>
>>But when this is executed, always is returned the following error:
>>
>>pg_ctl: Another postmaster may be running.  Trying to start postmaster anyway.
>>pg_ctl: cannot start postmaster
>>Examine the log output.
>>
>>Any sugestions !! What's wrong ?
>>
>>
>
>You don't want to restart the postmaster; suppose someone has a
>long-running query in progress at that moment.  As to what is going
>wrong, what does the log output say?
>
>You should use copytruncate as a logrotate option, so that you will not
>need to force the postmaster to close.
>
>This is my (working) setup:
>
>    $ cat /etc/logrotate.d/postgresql
>    /var/log/postgres.log {
>        daily
>        rotate 10
>        copytruncate
>        delaycompress
>        compress
>        notifempty
>        create 640 postgres postgres
>    }
>
>
>
Oliver,

I'm using the definition that you refer but now I have a problem.
Now, after one rotate, postgres created an empty file, postgres.log, but
is witing log on postgres.log.1.
Why's that ? Why didn't postgre started writing log in postgres.log, the
new file that was created ?

Thanks in advance
Luis Sousa


--
Luis Sousa
Especialista de Inform?tica
Gabinete de Gest?o de Informa??o, ext: 7837
Campus de Gambelas
Universidade do Algarve, tel: 289800900



Attachment

Re: Logrotate

From
Oliver Elphick
Date:
On Thu, 2002-11-28 at 10:11, Luis Sousa wrote:
> >You should use copytruncate as a logrotate option, so that you will not
> >need to force the postmaster to close.
> >
> >This is my (working) setup:
> >
> >    $ cat /etc/logrotate.d/postgresql
> >    /var/log/postgres.log {
> >        daily
> >        rotate 10
> >        copytruncate
> >        delaycompress
> >        compress
> >        notifempty
> >        create 640 postgres postgres
> >    }
> >
> >
> >
> Oliver,
>
> I'm using the definition that you refer but now I have a problem.
> Now, after one rotate, postgres created an empty file, postgres.log, but
> is witing log on postgres.log.1.
> Why's that ? Why didn't postgre started writing log in postgres.log, the
> new file that was created ?

The above is my setup and it works, so I don't know why yours wouldn't.
Is there a bug in logrotate?  What version are you running?  Mine is
3.6.5; copytruncate was added at 2.6, but there is no mention of any
problem with it in the subsequent changelog.


The fact that postgres is writing to postgres.log.1 shows that
copytruncate hasn't worked and a new log has been created, whereas the
old log should have been copied to postgres.log.1 and then truncated in
place.

Try removing the create option (which in fact shouldn't be needed at all
with copytruncate.)

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "The earth is the LORD'S, and the fullness thereof; the
      world, and they that dwell therein."       Psalms 24:1

Attachment