pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
current log file removal
6+ messages / 5 participants
[nested] [flat]

* current log file removal
@ 2020-11-26 13:40  Yambu <hyambu@gmail.com>
  0 siblings, 2 replies; 6+ messages in thread

From: Yambu @ 2020-11-26 13:40 UTC (permalink / raw)
  To: Pgsql-admin <pgsql-admin@lists.postgresql.org>

Hi

How can I safely remove the log file that is being used  currently and zip
it without interfering with the postgres server?

We are running out of space on the server and the logs are eating a lot of
space, we need to zip them without first stopping the server.

regards

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: current log file removal
@ 2020-11-26 13:53  Van Hoa Phan <s50600822@gmail.com>
  parent: Yambu <hyambu@gmail.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Van Hoa Phan @ 2020-11-26 13:53 UTC (permalink / raw)
  To: Yambu <hyambu@gmail.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>

Would this do?

cat /dev/null > my_log_file.log

On Fri, Nov 27, 2020 at 12:41 AM Yambu <hyambu@gmail.com> wrote:

> Hi
>
> How can I safely remove the log file that is being used  currently and zip
> it without interfering with the postgres server?
>
> We are running out of space on the server and the logs are eating a lot of
> space, we need to zip them without first stopping the server.
>
> regards
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: current log file removal
@ 2020-11-26 14:03  Holger Jakobs <holger@jakobs.com>
  parent: Yambu <hyambu@gmail.com>
  1 sibling, 2 replies; 6+ messages in thread

From: Holger Jakobs @ 2020-11-26 14:03 UTC (permalink / raw)
  To: pgsql-admin@lists.postgresql.org

The ordinary log rotation should do.

These are the default settings (therefore commented with a # in 
postgresql.conf):

#log_rotation_age = 1d                  # Automatic rotation of logfiles 
will
                                         # happen after that time.  0 
disables.
#log_rotation_size = 10MB               # Automatic rotation of logfiles 
will
                                         # happen after that much log 
output.
                                         # 0 disables.

So your log files will not exceed 10 MB.

Of course, you can to this manually as well. Just rename the current 
logfile,  a new one will be created.

Then gzip or bzip2 or xz the old one.

Am 26.11.20 um 14:40 schrieb Yambu:
> Hi
>
> How can I safely remove the log file that is being used currently and 
> zip it without interfering with the postgres server?
>
> We are running out of space on the server and the logs are eating a 
> lot of space, we need to zip them without first stopping the server.
>
> regards

-- 
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012



Attachments:

  OpenPGP_signature (application/pgp-signature, 202B) download

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: current log file removal
@ 2020-11-26 14:46  Yambu <hyambu@gmail.com>
  parent: Holger Jakobs <holger@jakobs.com>
  1 sibling, 1 reply; 6+ messages in thread

From: Yambu @ 2020-11-26 14:46 UTC (permalink / raw)
  To: Holger Jakobs <holger@jakobs.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>

Hi

When I renamed log file, there was no new one created, do I need to reload
postgres?

regards

On Thu, Nov 26, 2020 at 4:03 PM Holger Jakobs <holger@jakobs.com> wrote:

> The ordinary log rotation should do.
>
> These are the default settings (therefore commented with a # in
> postgresql.conf):
>
> #log_rotation_age = 1d                  # Automatic rotation of logfiles
> will
>                                          # happen after that time.  0
> disables.
> #log_rotation_size = 10MB               # Automatic rotation of logfiles
> will
>                                          # happen after that much log
> output.
>                                          # 0 disables.
>
> So your log files will not exceed 10 MB.
>
> Of course, you can to this manually as well. Just rename the current
> logfile,  a new one will be created.
>
> Then gzip or bzip2 or xz the old one.
>
> Am 26.11.20 um 14:40 schrieb Yambu:
> > Hi
> >
> > How can I safely remove the log file that is being used currently and
> > zip it without interfering with the postgres server?
> >
> > We are running out of space on the server and the logs are eating a
> > lot of space, we need to zip them without first stopping the server.
> >
> > regards
>
> --
> Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012
>
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: current log file removal
@ 2020-11-26 14:58  Paul Förster <paul.foerster@gmail.com>
  parent: Yambu <hyambu@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Paul Förster @ 2020-11-26 14:58 UTC (permalink / raw)
  To: Yambu <hyambu@gmail.com>; +Cc: Holger Jakobs <holger@jakobs.com>; Pgsql-admin <pgsql-admin@lists.postgresql.org>

Hi,

> On 26. Nov, 2020, at 15:46, Yambu <hyambu@gmail.com> wrote:
> 
> When I renamed log file, there was no new one created, do I need to reload postgres?

a new log file will be created when necessary and not just for fun. So, if there is an event that needs logging, then the log file will be written to. If it doesn't exist, then it will be created.

If your log level permits, then you can provoke that, but it's really not necessary to do that.

Cheers,
Paul




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: current log file removal
@ 2020-11-26 17:25  Ron <ronljohnsonjr@gmail.com>
  parent: Holger Jakobs <holger@jakobs.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Ron @ 2020-11-26 17:25 UTC (permalink / raw)
  To: pgsql-admin@lists.postgresql.org

I set these values in postgresql.conf, then have a cron job which runs just 
after midnight that compresses yesterday's log files. That same cron job 
deletes compressed files older than X days.

log_destination = 'stderr'
logging_collector = on
log_directory = '/your/data/location/12/pg_log' # assuming v12, of course
log_filename = 'postgresql-%F.log'
log_rotation_age = 1d

On 11/26/20 8:03 AM, Holger Jakobs wrote:
> The ordinary log rotation should do.
>
> These are the default settings (therefore commented with a # in 
> postgresql.conf):
>
> #log_rotation_age = 1d                  # Automatic rotation of logfiles will
>                                         # happen after that time. 0 disables.
> #log_rotation_size = 10MB               # Automatic rotation of logfiles will
>                                         # happen after that much log output.
>                                         # 0 disables.
>
> So your log files will not exceed 10 MB.
>
> Of course, you can to this manually as well. Just rename the current 
> logfile,  a new one will be created.
>
> Then gzip or bzip2 or xz the old one.
>
> Am 26.11.20 um 14:40 schrieb Yambu:
>> Hi
>>
>> How can I safely remove the log file that is being used currently and zip 
>> it without interfering with the postgres server?
>>
>> We are running out of space on the server and the logs are eating a lot 
>> of space, we need to zip them without first stopping the server.
>>
>> regards
>

-- 
Angular momentum makes the world go 'round.





^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2020-11-26 17:25 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-26 13:40 current log file removal Yambu <hyambu@gmail.com>
2020-11-26 13:53 ` Van Hoa Phan <s50600822@gmail.com>
2020-11-26 14:03 ` Holger Jakobs <holger@jakobs.com>
2020-11-26 14:46   ` Yambu <hyambu@gmail.com>
2020-11-26 14:58     ` Paul Förster <paul.foerster@gmail.com>
2020-11-26 17:25   ` Ron <ronljohnsonjr@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox