From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 951C459CAF for ; Sat, 2 Apr 2016 02:02:17 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 29C54E0879; Sat, 2 Apr 2016 02:02:06 +0000 (UTC) Received: from acheron.yagibdah.de (acheron.yagibdah.de [185.55.75.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 44D12E0875 for ; Sat, 2 Apr 2016 02:02:02 +0000 (UTC) Received: from heimdali.yagibdah.de ([192.168.3.20]) by acheron.yagibdah.de with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.85) (envelope-from ) id 1amAsy-0008Bl-KT for gentoo-user@lists.gentoo.org; Sat, 02 Apr 2016 04:02:00 +0200 Received: from lee by heimdali.yagibdah.de with local (Exim 4.85) (envelope-from ) id 1amAsy-00063K-Ib for gentoo-user@lists.gentoo.org; Sat, 02 Apr 2016 04:02:00 +0200 From: lee To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] logrotate: name of log file after it's rotated? In-Reply-To: <56F5A0DD.1060004@gmail.com> (Alan McKinnon's message of "Fri, 25 Mar 2016 22:34:37 +0200") Date: Sat, 02 Apr 2016 04:01:54 +0200 Organization: my virtual residence Message-ID: <87h9fklqel.fsf@heimdali.yagibdah.de> References: <87wpoqlr02.fsf@heimdali.yagibdah.de> <56F5A0DD.1060004@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Mail-Followup-To: gentoo-user@lists.gentoo.org Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain X-Archives-Salt: 82ed3216-a746-490c-a57f-84f73626ee49 X-Archives-Hash: cc1ec9ff8d23fcf0869b5a5893571282 Alan McKinnon writes: > On 25/03/2016 13:46, lee wrote: >> >> Hi, >> >> is there a built-in way (like a place holder) to figure out what name a >> rotated log file has been given by logrotate? >> >> Here's what I'm trying to do: >> >> >> ,---- [ cat /etc/logrotate.d/exim } >> | /var/log/exim/exim*.log { >> | daily >> | missingok >> | rotate 800 >> | compress >> | delaycompress >> | notifempty >> | create 640 mail mail >> | postrotate >> | /usr/sbin/eximstats | mail -s "eximstats" root >> | endscript >> | } >> `---- >> >> >> I want replaced with the name the log file that >> has been rotated has been renamed to. I can think of ways to do this >> otherwise, like writing a script that figures out the name of the file, >> or using 'prerotate' instead. >> >> It just won't make any sense if logrotate doesn't already have some kind >> of place holder for this. >> > > > It depends. There are options to tell logrotate to use, or not use, > dates in the new filename, and what compression to use or not use. So > the names can vary. Exactly, and that's why there needs to be some sort of place holder for the file name. > By far the easiest solution is to put your "| mail" into prerotate > section. That way you know exactly what the name is. Or maybe not due to > that * in the name glob... The problem is that the file can be written to while it is being examined when the examination is performed before it is rotated. That can lead to false results of the examination. > Perhaps look into renamecopy described in man logrotate Thanks, that sounds as if it will provide exactly what I'm looking for :)