Re: How to get syslog to log in GMT or any other time zone
- From: James Harris <james.harris.1@xxxxxxxxxxxxxx>
- Date: Wed, 1 Apr 2009 03:38:31 -0700 (PDT)
On 31 Mar, 22:59, James Harris <james.harri...@xxxxxxxxxxxxxx> wrote:
I was slightly surprised to see the timestamps in syslog as follows
over the recent time change
Mar 29 00:58:01
Mar 29 00:59:01
Mar 29 02:00:01
Mar 29 02:00:25
Each line is followed by the server name and the log entry. Notably,
there's no indication of how the timezone changed.
Presumably this would be worse when the clocks change the other way in
that multiple entries would have the same time stamp.
I cannot find any way to change how sysklogd gets or formats its time.
Fixing logs to use GMT would be ideal.
Any ideas how to change the time zone in the logs? If relevant, this
is Ubuntu.
Thanks for the replies. I think I have a fix. In case anyone else
wants to do the same thing here is the solution.
I noticed (largely by guesswork) that the system date command takes
notice of a TZ environment variable.
$ echo $TZ
$ date
Wed Apr 1 11:15:58 BST 2009
$ export TZ=UTC
$ date
Wed Apr 1 10:16:16 UTC 2009
$
It turns out syslogd also honours the variable though this seems to be
undocumented. Anyway /etc/init.d/sysklogd contains this line
test ! -r /etc/default/syslogd || . /etc/default/syslogd
which picks up environment variables from the included file so I added
TZ=UTC to /etc/default/syslogd and restarted the daemon with
sudo /etc/init.d/sysklogd restart
Now the entries in syslog and other logs have the GMT time stamp.
Hopefully this should mean they remain stable when the clocks next
change.
James
.
- Follow-Ups:
- Re: How to get syslog to log in GMT or any other time zone
- From: James Harris
- Re: How to get syslog to log in GMT or any other time zone
- References:
- How to get syslog to log in GMT or any other time zone
- From: James Harris
- How to get syslog to log in GMT or any other time zone
- Prev by Date: Re: How to get syslog to log in GMT or any other time zone
- Next by Date: Re: How to get syslog to log in GMT or any other time zone
- Previous by thread: Re: How to get syslog to log in GMT or any other time zone
- Next by thread: Re: How to get syslog to log in GMT or any other time zone
- Index(es):
Relevant Pages
|
Loading