Alan McKinnon <alan.mckin...@gmail.com> 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 <name-of-rotated-file> | mail -s >> "eximstats" root >> | endscript >> | } >> `---- >> >> >> I want <name-of-rotated-file> 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 :)