Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

rotatelogs: log name is one day off

21 views
Skip to first unread message

i5mast

unread,
Feb 8, 2010, 3:27:43 PM2/8/10
to
Hello, I have the following configuration.
OS: CentOS release 5.4 (Final)
Server version: Apache/2.2.14 (Unix)
Server built: Oct 26 2009 06:33:38
Cpanel::Easy::Apache v3.2.0 rev4801

I have a virtual host configured in httpd.conf
CustomLog "|/usr/local/apache/bin/rotatelogs -l /usr/local/apache/logs/
accesslog_%Y_%m_%d.log 86400" combined
ErrorLog "|/usr/local/apache/bin/rotatelogs -l /usr/local/apache/logs/
errorlog_%Y_%m_%d.log 86400"

My issue is that accesslog and errorlog files are named
usr/local/apache/logs/accesslog_2010_02_07.log
/usr/local/apache/logs/errorlog_2010_02_07.log

Today's date is
# date
Mon Feb 8 15:18:25 EST 2010

So I expect the files to be named accesslog_2010_02_08.log and
errorlog_2010_02_08.log. If I set the rotation time to 86300 then
dates are ok.

Does anybody know what is going on? I have Apache 2.2.9 on Solaris 10
x86 and I have no problems with rotatelogs there.

Thank you.

Luuk

unread,
Feb 8, 2010, 3:51:34 PM2/8/10
to
Op 8-2-2010 21:27, i5mast schreef:

This rotatelogs with 86400 is probably OK.
It means that log are rotated every 86400 seconds.

But it does not state WHEN, as on what time during this 86400 seconds,
this will happen.......

--
Luuk

i5mast

unread,
Feb 8, 2010, 4:14:58 PM2/8/10
to
On Feb 8, 3:51 pm, Luuk <l...@invalid.lan> wrote:
> This rotatelogs with 86400 is probably OK.
> It means that log are rotated every 86400 seconds.
>
> But it does not state WHEN, as on what time during this 86400 seconds,
> this will happen.......

It does say that it rotates at midnight http://httpd.apache.org/docs/2.2/programs/rotatelogs.html

--
i5mast

Luuk

unread,
Feb 8, 2010, 4:28:58 PM2/8/10
to
Op 8-2-2010 22:14, i5mast schreef:

But is also says this:
This creates the files /var/logs/logfile.nnnn where nnnn is the system
time at which the log nominally starts (this time will always be a
multiple of the rotation time, so you can synchronize cron scripts with
it). At the end of each rotation time (here after 24 hours) a new log is
started.

I have my log configured like:
CustomLog /var/log/apache2/access_log combined

and my /etc/logratate.d/apache2 script is configured to rotatie the logs...
--
Luuk

i5mast

unread,
Feb 8, 2010, 5:01:58 PM2/8/10
to
On Feb 8, 4:28 pm, Luuk <l...@invalid.lan> wrote:
> But is also says this:
> This creates the files /var/logs/logfile.nnnn where nnnn is the system
> time at which the log nominally starts (this time will always be a
> multiple of the rotation time, so you can synchronize cron scripts with
> it). At the end of each rotation time (here after 24 hours) a new log is
> started.
>
> I have my log configured like:
> CustomLog /var/log/apache2/access_log combined
>
> and my /etc/logratate.d/apache2 script is configured to rotatie the logs...
> --
> Luuk

I'm not sure what you're trying to say in the post above. The log
files _are_ being rotated at midnight. I can see that right now. I'm
using -l option to use a local timezone instead of UTC. The issue is
that the date in the name of the log file is off.
For example, accesslog_2010_02_06.log has _only_ http requests dated 7/
Feb/2010, accesslog_2010_02_07.log has only http requests dated 8/Feb/
2010.

If I started my Apache right now at 5:00pm EST, a log file name would
have a date of yesterday which is wrong. It should use current year,
month and day. This is how my other configuration behaves (Apache
2.2.6 actually).

/etc/logrotate.d is not an option for me. It does not keep all log
files :(

--
i5mast

Luuk

unread,
Feb 8, 2010, 5:13:00 PM2/8/10
to
Op 8-2-2010 23:01, i5mast schreef:

> On Feb 8, 4:28 pm, Luuk <l...@invalid.lan> wrote:
>> But is also says this:
>> This creates the files /var/logs/logfile.nnnn where nnnn is the system
>> time at which the log nominally starts (this time will always be a
>> multiple of the rotation time, so you can synchronize cron scripts with
>> it). At the end of each rotation time (here after 24 hours) a new log is
>> started.
>>
>> I have my log configured like:
>> CustomLog /var/log/apache2/access_log combined
>>
>> and my /etc/logratate.d/apache2 script is configured to rotatie the logs....

>> --
>> Luuk
>
> I'm not sure what you're trying to say in the post above. The log
> files _are_ being rotated at midnight. I can see that right now. I'm
> using -l option to use a local timezone instead of UTC. The issue is
> that the date in the name of the log file is off.
> For example, accesslog_2010_02_06.log has _only_ http requests dated 7/
> Feb/2010, accesslog_2010_02_07.log has only http requests dated 8/Feb/
> 2010.
>
> If I started my Apache right now at 5:00pm EST, a log file name would
> have a date of yesterday which is wrong. It should use current year,
> month and day. This is how my other configuration behaves (Apache
> 2.2.6 actually).
>
> /etc/logrotate.d is not an option for me. It does not keep all log
> files :(
>
> --
> i5mast

hmmm, ok i see......

I can live with a logfile name 2010_02_06 which only containts logs from
7 feb 2010, thats why i never ever thought about this 'problem'
(because its no problem to /me)

;-)

i hope someone else has good suggestions for you

--
Luuk

Luuk

unread,
Feb 9, 2010, 5:06:53 AM2/9/10
to
Op 8-2-2010 23:01, i5mast schreef:
> /etc/logrotate.d is not an option for me. It does not keep all log
> files :(
>
> --
> i5mast


"/var/log/httpd/access.log" /var/log/httpd/error.log {
rotate 999999
daily
postrotate
/sbin/killall -HUP httpd
endscript
}

will keep all logfiles, but they wont contain a data in the filename

--
Luuk

i5mast

unread,
Feb 9, 2010, 4:18:23 PM2/9/10
to

I have several VirtualHosts and each of them has CustomLog and
ErrorLog. VirtualHosts are added thru CPanel's console and its
template system. I can tweak the templates to have the desired
CustomLog and ErrorLog. I don't event want to think about the kung-fu
required to maintain /etc/logrotate.d this way :)

Regards,
--
i5mast

"Álvaro G. Vicario"

unread,
Feb 10, 2010, 3:13:05 AM2/10/10
to

If I recall correctly, you can use wildcards. But, of course, once
Cpanel is involved you're pretty limited in almost everything :)

--
-- http://alvaro.es - �lvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programaci�n web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--

i5mast

unread,
Feb 24, 2010, 3:06:23 PM2/24/10
to
On Feb 8, 3:27 pm, i5mast <mstrum...@gmail.com> wrote:
> Hello, I have the following configuration.
> OS: CentOS release 5.4 (Final)
> Server version: Apache/2.2.14 (Unix)
> Server built:   Oct 26 2009 06:33:38
> Cpanel::Easy::Apache v3.2.0 rev4801
>

I think I got to the bottom (almost) of this issue. The issue is that
system calls localtime/gmtime(t) give me incorrect time. Given this
perl script:

#!/usr/local/bin/perl
use POSIX qw(strftime);
$now_string = strftime "%a %b %e %H:%M:%S %Y", localtime(1266969600);
print $now_string."\n";
# or for GMT formatted appropriately for your locale:
$now_string = strftime "%a %b %e %H:%M:%S %Y", gmtime(1266969600);
print $now_string."\n";

I get the following:
Tue Feb 23 18:59:36 2010
Tue Feb 23 23:59:36 2010

I expect to see this:
Tue Feb 23 19:00:00 2010
Wed Feb 24 00:00:00 2010

The time is off by 24 seconds. Any ideas? Maybe hardware clock is off?

--
i5mast

HansH

unread,
Feb 24, 2010, 5:02:25 PM2/24/10
to
"i5mast" <mstr...@gmail.com> schreef in bericht
news:277eb25a-13c7-4c70...@k6g2000prg.googlegroups.com...

>On Feb 8, 3:27 pm, i5mast <mstrum...@gmail.com> wrote:
>> Hello, I have the following configuration.
>> OS: CentOS release 5.4 (Final)
>> Server version: Apache/2.2.14 (Unix)
>> Server built: Oct 26 2009 06:33:38
>> Cpanel::Easy::Apache v3.2.0 rev4801
>>
>
>I think I got to the bottom (almost) of this issue. The issue is that
>system calls localtime/gmtime(t) give me incorrect time. Given this
>perl script:
>
>#!/usr/local/bin/perl
>use POSIX qw(strftime);
>$now_string = strftime "%a %b %e %H:%M:%S %Y", localtime(1266969600);
>print $now_string."\n";
>
>Tue Feb 23 18:59:36 2010
>
>I expect to see this:
>Tue Feb 23 19:00:00 2010
>
>The time is off by 24 seconds. Any ideas?

Since Januari 1st, 1970 the net count of leap seconds is 24 ...
http://en.wikipedia.org/wiki/Leap_second
Your CentOS appears to be using a LeapSecond aware TimeZone setting, compare
the two results of
$ TZ=CET date; TZ=right/CET date;


i5mast

unread,
Feb 25, 2010, 2:03:57 PM2/25/10
to
On Feb 24, 5:02 pm, "HansH" <ha...@invalid.invalid> wrote:
> >The time is off by 24 seconds. Any ideas?
>
> Since Januari 1st, 1970 the net count of leap seconds is 24 ...http://en.wikipedia.org/wiki/Leap_second

> Your CentOS appears to be using a LeapSecond aware TimeZone setting, compare
> the two results of
> $ TZ=CET date; TZ=right/CET date;

# TZ=CET date && TZ=right/CET date
Thu Feb 25 20:03:35 CET 2010
Thu Feb 25 20:03:11 CET 2010

Yes, that was the issue. Thank you.

0 new messages