Skip site navigation (1) Skip section navigation (2)

rotating log files

From: Jelle Ouwerkerk <jelle(at)openface(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: rotating log files
Date: 2001-04-27 14:28:19
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
I think I may have found an answer to my own problem:

> What is a good solution for rotating postgresql log files?

> I'm running 'Linux 2.2.16-22smp #1 SMP i686 unknown' and a solution that
> was proposed to me was to use cron and a program called logrotate:

> Unfortunately, after replacing/rotating/compressing the database log
> file, the new log file remains empty. I have a feeling that postgres has
> lost the reference to the original log file and that the new log data is
> lost into the void.

The (new) contents of /etc/logrotate.d/postgres:

# start

/var/log/postgresql.log {
           rotate 10
           create 0664 postgres postgres
             /etc/rc.d/init.d/postgresql restart


From the logrotate man page:

size size
              Log files are rotated when they  grow  bigger  then
              size  bytes.

              Log  files  are  rotated  if the current weekday is
              less then the weekday of the last  rotation  or  if
              more  then  a  week has passed since the last rota­

              The lines between postrotate and endscript (both of
              which must appear on lines by themselves) are  exe­
              cuted  after  the log file is rotated. These direc­
              tives may only appear inside of a log file  defini­
              tion.  See prerotate as well.

              Normally, prescript and postscript scripts are  run
              for  each log which is rotated, meaning that a sin­
              gle script may be run multiple times for  log  file
              entries  which  match  multiple  files (such as the
              /var/log/news/* example). If sharedscript is speci­
              fied,  the scripts are only run once, no matter how
              many logs match the  wildcarded  pattern.   A  side
              effect  of  this  option  is  that  the scripts are
              always executed, even if no logs are rotated (if it
              is  not specified, the scripts are run only if logs
              are actually rotated) (this overrides the noshared­
              scripts option).

Any comments about this setup are welcome. :)

Jelle Ouwerkerk
Software Developer 
Openface Internet Inc.
Montreal, Quebec, Canada


pgsql-general by date

Next:From: Gregory WoodDate: 2001-04-27 14:30:34
Subject: Re: SQL Where LIKE - Range it!
Previous:From: Peter T MountDate: 2001-04-27 14:16:15
Subject: Re: how to migrate from SQL Server7 to PostgreSQL7??

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group