Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tclpt-002XJn-BI for pgsql-general@arkaria.postgresql.org; Tue, 28 Jan 2025 13:41:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tclpr-001CpY-HS for pgsql-general@arkaria.postgresql.org; Tue, 28 Jan 2025 13:40:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tclpr-001CpP-52 for pgsql-general@lists.postgresql.org; Tue, 28 Jan 2025 13:40:59 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tclpn-001xvr-2O for pgsql-general@postgresql.org; Tue, 28 Jan 2025 13:40:58 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-aaf900cc7fbso918830266b.3 for ; Tue, 28 Jan 2025 05:40:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738071654; x=1738676454; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=gV1KkIQ+J8N/9THxzS2NS+UtJXYW3FEBQj9cJYvFD8c=; b=hhojv/+X5iYjVn8fDNA3kKdEx0Ab1PjTySlAEeI+xaS90KqqWV3u3w+T2EXUYa/Wjq R9Tq30ql9FGxTKroG34ZxLp4e6OtKdEfx5Y6cJ062HmCiQ+FaD1tQZDKdc+8S/bUboeP 8bgbdT0Tkq+WqmWsZ3pWSq4h6+0fNTQ1o6aUuwtMbMg7tPcFmX1xxtJFZAcg3djuBuHB DCantQdTeO+ELfBY4RJaRumcJM7lEy5Kpp6VMuY95a0YgCTUz8WN7B/iWcQyqcIoBOEW P+uyHHTPqekRCC8UJnPaBUc4VYTnHaFJTSR6mlAs4V0Y+wjqTbu1w/wGg8Gz2EnNximq v3Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738071654; x=1738676454; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gV1KkIQ+J8N/9THxzS2NS+UtJXYW3FEBQj9cJYvFD8c=; b=qEsb0j2mnFPvrt3SSYfDGzZS7ySd914ccR0WXs/cal1VMpDyXuk6Phzt/HX4g2xT2S NcGxxV7tSS0YigoIew+egGPCMveEBuEww/gdNnbUoIbvFXptDsYJHPKTFOg3mZ4+P4dI rTNRlAKmzVU5yiAown4s7RpjW9WpwuMa3acm2n0xZlDK0+fdpzjrsuFLjpCPsHCPswxe hdzeALe0XeHdTvIdrc8pYUTuWJu5s/WAeo1hUG8gO5/mXPfEgPcXmbvbGkyW/unHQH+1 q+M5hCSo6/hCOPe6gyyhRC01kLgve03K3u7lK9/h8qqvTthYDhTcyESb6x11Vm8gTuDi GQfg== X-Gm-Message-State: AOJu0Yw2wvwIg6IyI0X1W/GOoudSVXAKQeK0IBPYgWE7kjtGALoVl4Ez sgqBAUrPYgqYM74HMn/QLkmuHtTFgUuMMrWzIwhavqApQ5rMYwqojEU5/6pQziya/b9v2FAz0uI +3uxKAgmvrKLv44xWYZvU61kaK/bURhr2gmU= X-Gm-Gg: ASbGnctyXFqMzBLZm9ttkjfII6Uu8vtotp5VxkVnC24IXKKHLqPRrUOBS4AjHtfpc4h EaFtSsAiWRuhLNpYME9V2bFfSl+3Gbf4t7TRy0Rv0t63ZiE/ylfv+y7kdN8VmRsg9IOYKJ5o= X-Google-Smtp-Source: AGHT+IE1J0F4GX8WQVK8IE/lE/SzVCtHsphy2awsP3TppO16Zq6F3q5jHDri/ohylkAEUkyiSsqqjbmqwbEiRxxFxZQ= X-Received: by 2002:a17:906:c108:b0:aa6:79fa:b47d with SMTP id a640c23a62f3a-ab38b0b8138mr4283539566b.1.1738071653628; Tue, 28 Jan 2025 05:40:53 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Paul Brindusa Date: Tue, 28 Jan 2025 13:40:42 +0000 X-Gm-Features: AWEUYZmrTNvsRhh6yOmTX9qVkyQBZYS1xJFzklLEbFm-vPZzLfN4P66U-DSLOc8 Message-ID: Subject: Re: Log retention query To: Laurenz Albe Cc: pgsql-general Content-Type: multipart/alternative; boundary="0000000000008245c0062cc45711" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000008245c0062cc45711 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable @Junwang apologies, I should have mentioned that we've tried setting up a crontab and it has not worked. Have you got something similar working? @Laurenz: log_filename: postgresql-%Y-%m-%d.log -- if we redo the syntax can we make it trigger garbage collection on 180 days? On Tue, Jan 28, 2025 at 1:28=E2=80=AFPM Laurenz Albe wrote: > On Tue, 2025-01-28 at 09:57 +0000, Paul Brindusa wrote: > > Good morning everyone, > > > > Before I get on with today's problem, I would like to say how much I > appreciate this community and everything that you do for end users. > > > > In today's problem I would like to understand if the following lines in > our config handle the log rotation for our clusters? > > > > log_checkpoints: on > > logging_collector: on > > log_truncate_on_rotation: on > > log_rotation_age: 1d > > log_rotation_size: 1GB > > log_error_verbosity: verbose > > > > I have been deleting the logs manually for the last month, since I am > confused how the log collector rotates them. > > > > Am looking to delete logs older than 180 days. What are we doing wrong > in the config? > > It all depends on how you configured "log_filename". > > If the setting is "postgresql-%a.log" or "postgresql-%d.log", PostgreSQL > will recycle the old log files once a week or once a month. > > If the setting is the default "postgresql-%Y-%m-%d_%H%M%S.log", the same > log file name will never be reused, and there will be no log rotation. > > PostgreSQL doesn't actively delete old log files. > > Yours, > Laurenz Albe > --=20 Kind Regards, Paul Brindusa paulbrindusa88@gmail.com --0000000000008245c0062cc45711 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
@Junwang apologies, I should have mentioned that=C2=A0 we&= #39;ve tried setting up a crontab and it has not worked. Have you got somet= hing similar working?

@Laurenz: log_filename: postgr= esql-%Y-%m-%d.log=C2=A0 -- if we redo the syntax can we make it trigger gar= bage collection on 180 days?

On Tue, Jan 28,= 2025 at 1:28=E2=80=AFPM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
On Tue, 2025-01-28 at 09:57 +0000, Paul = Brindusa wrote:
> Good morning everyone,
>
> Before I get on with today's problem, I would like to say how much= I appreciate this community and everything that you do for end users.
>
> In today's problem I would like to understand if the following lin= es in our config handle the log rotation for our clusters?
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 log_checkpoints: on
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 logging_collector: on
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 log_truncate_on_rotation: on
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 log_rotation_age: 1d
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 log_rotation_size: 1GB
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 log_error_verbosity: verbose
>
> I have been deleting the logs manually for the last month, since I am = confused how the log collector rotates them.=C2=A0
>
> Am looking to delete logs older than 180 days. What are we doing=C2=A0= wrong in the config?

It all depends on how you configured "log_filename".

If the setting is "postgresql-%a.log" or "postgresql-%d.log&= quot;, PostgreSQL
will recycle the old log files once a week or once a month.

If the setting is the default "postgresql-%Y-%m-%d_%H%M%S.log", t= he same
log file name will never be reused, and there will be no log rotation.

PostgreSQL doesn't actively delete old log files.

Yours,
Laurenz Albe


--
Kind Regards,
Paul Brindusa
=

--0000000000008245c0062cc45711--