1 |
Alan McKinnon <alan.mckinnon@×××××.com> writes: |
2 |
|
3 |
> On 25/03/2016 13:46, lee wrote: |
4 |
>> |
5 |
>> Hi, |
6 |
>> |
7 |
>> is there a built-in way (like a place holder) to figure out what name a |
8 |
>> rotated log file has been given by logrotate? |
9 |
>> |
10 |
>> Here's what I'm trying to do: |
11 |
>> |
12 |
>> |
13 |
>> ,---- [ cat /etc/logrotate.d/exim } |
14 |
>> | /var/log/exim/exim*.log { |
15 |
>> | daily |
16 |
>> | missingok |
17 |
>> | rotate 800 |
18 |
>> | compress |
19 |
>> | delaycompress |
20 |
>> | notifempty |
21 |
>> | create 640 mail mail |
22 |
>> | postrotate |
23 |
>> | /usr/sbin/eximstats <name-of-rotated-file> | mail -s "eximstats" root |
24 |
>> | endscript |
25 |
>> | } |
26 |
>> `---- |
27 |
>> |
28 |
>> |
29 |
>> I want <name-of-rotated-file> replaced with the name the log file that |
30 |
>> has been rotated has been renamed to. I can think of ways to do this |
31 |
>> otherwise, like writing a script that figures out the name of the file, |
32 |
>> or using 'prerotate' instead. |
33 |
>> |
34 |
>> It just won't make any sense if logrotate doesn't already have some kind |
35 |
>> of place holder for this. |
36 |
>> |
37 |
> |
38 |
> |
39 |
> It depends. There are options to tell logrotate to use, or not use, |
40 |
> dates in the new filename, and what compression to use or not use. So |
41 |
> the names can vary. |
42 |
|
43 |
Exactly, and that's why there needs to be some sort of place holder for |
44 |
the file name. |
45 |
|
46 |
> By far the easiest solution is to put your "| mail" into prerotate |
47 |
> section. That way you know exactly what the name is. Or maybe not due to |
48 |
> that * in the name glob... |
49 |
|
50 |
The problem is that the file can be written to while it is being |
51 |
examined when the examination is performed before it is rotated. That |
52 |
can lead to false results of the examination. |
53 |
|
54 |
> Perhaps look into renamecopy described in man logrotate |
55 |
|
56 |
Thanks, that sounds as if it will provide exactly what I'm looking for |
57 |
:) |