pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: current log file removal
Date: Thu, 26 Nov 2020 11:25:50 -0600
Message-ID: <53a8b79d-6031-45d8-b213-028183750251@gmail.com> (raw)
In-Reply-To: <a0b34226-3b66-44bd-c2da-ae0ef3b32100@jakobs.com>
References: <CALhHtcAyBC9PsQDb-h1LaCetV85JPH7o4Md6T7_Qh0hd-6sk1Q@mail.gmail.com>
	<a0b34226-3b66-44bd-c2da-ae0ef3b32100@jakobs.com>

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.





view thread (6+ messages)

Message-ID: <53a8b79d-6031-45d8-b213-028183750251@gmail.com>
Permalink:  ../53a8b79d-6031-45d8-b213-028183750251@gmail.com/
Also on:    postgresql.org/message-id/53a8b79d-6031-45d8-b213-028183750251@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: ronljohnsonjr@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: current log file removal
  In-Reply-To: <53a8b79d-6031-45d8-b213-028183750251@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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