Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] logrotate: name of log file after it's rotated?
Date: Fri, 25 Mar 2016 20:34:53
Message-Id: 56F5A0DD.1060004@gmail.com
In Reply to: [gentoo-user] logrotate: name of log file after it's rotated? by lee
1 On 25/03/2016 13:46, lee wrote:
2 >
3 > Hi,
4 >
5 > is there a built-in way (like a place holder) to figure out what name a
6 > rotated log file has been given by logrotate?
7 >
8 > Here's what I'm trying to do:
9 >
10 >
11 > ,---- [ cat /etc/logrotate.d/exim }
12 > | /var/log/exim/exim*.log {
13 > | daily
14 > | missingok
15 > | rotate 800
16 > | compress
17 > | delaycompress
18 > | notifempty
19 > | create 640 mail mail
20 > | postrotate
21 > | /usr/sbin/eximstats <name-of-rotated-file> | mail -s "eximstats" root
22 > | endscript
23 > | }
24 > `----
25 >
26 >
27 > I want <name-of-rotated-file> replaced with the name the log file that
28 > has been rotated has been renamed to. I can think of ways to do this
29 > otherwise, like writing a script that figures out the name of the file,
30 > or using 'prerotate' instead.
31 >
32 > It just won't make any sense if logrotate doesn't already have some kind
33 > of place holder for this.
34 >
35
36
37 It depends. There are options to tell logrotate to use, or not use,
38 dates in the new filename, and what compression to use or not use. So
39 the names can vary.
40
41 By far the easiest solution is to put your "| mail" into prerotate
42 section. That way you know exactly what the name is. Or maybe not due to
43 that * in the name glob...
44
45 Perhaps look into renamecopy described in man logrotate
46
47 --
48 Alan McKinnon
49 alan.mckinnon@×××××.com

Replies

Subject Author
Re: [gentoo-user] logrotate: name of log file after it's rotated? lee <lee@××××××××.de>