On Apr 06 23:52:31, Antti Harri wrote: > On Tue, 6 Apr 2010, Jan Stary wrote: > >> No it's not. Unless you have some heavy traffic just around the midnight >> that is the border between months, the above newsyslog line makes >> the just-rotated access_log.0.gz contains the log of the >> month-that-just-ended. > > OK. How do I reliably get month and year out of the file?
You already know that. If it's April 2010 now, then access_log.0.gz contains the logs of March 2010. (Beware the logs of March!) If you want to get the date _out_of_the_file_ (why would you, you already know that), it's in each and every line of the access_log: 158.108.213.20 - - [07/Apr/2010:08:01:48 +0200] "GET /hoeg/ HTTP/1.0" 200 3771 > Month I can get from the newsyslog output it puts in the logs, > getting year without doing some sort of nasty kludge is hard. > > m=$(zfgrep "logfile turned over" "$file" | tail -n 1 | cut -b 1-3) This is the month (which you already know anyway). The year is not even present in the "turned over" messages. But again, it is present in each and every of the log records. >>> I'm using www/visitors to produce something meaningful from those >>> logs, and I would like to generate stats just once for a certain >>> time period so I can later see stats further than one year that newsyslog >>> keeps. >> >> webalizer > > I told I'm using visitors. Which apparently cannot do it (or what exactly is your problem?). Try webalizer, it doesn't depend on log files being particularly named and/or sorted, juts reads the individual records, remembers previous periods, what was already processed, etc.