Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

So imagine there are ~100 servers with different timezones (not all diff., but many-many timezones). There are outputs on the server logs like:

server1:BFE4C025   0420201413 P H sysplanar0     UNDETERMINED ERROR
server2:BFE4C025   0421032413 P H sysplanar0     UNDETERMINED ERROR

-> so they are in server time (different timezones) ->

0420201413 = 2013.04.20. 20:14
0421032413 = 2013.04.21 03:24

Converting ex.: 0421032413 to 2013.04.21 03:24 is trivial. But: again the server time differs, if I give out the "date" command on these two servers in the exact same time:

server1:Tue Apr 23 07:23:24 EDT 2013
server2:Tue Apr 23 13:23:24 MESZ 2013

I get this. But I need the mentioned logs (only that few line/server) in one timezone. Why? Because it's very-very usefull to know when did exactly things happen in your timezone, ex.: CET TZ.

Q: how can I convert the server logs time to Central European time?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

You can use date to print date timestamp and store it with log message.

$ TZ='Europe/Warsaw' date
wto, 23 kwi 2013, 17:11:48 CEST
$ TZ='America/Los_Angeles' date
wto, 23 kwi 2013, 08:11:56 PDT
$ date --universal
wto, 23 kwi 2013, 15:13:14 UTC

Use tzselect to find time zones.

share|improve this answer
add comment

If you just want to convert existing syslog files you can e.g. use a small python/perl/ruby program to change Tue Apr 23 07:23:24 EDT 2013 in something with UTC (or CET).

If you want to have more control over the time format that is written in the log file, you might want to look at syslog-ng. Its tsformat() function allows you to configure the time format e.g. to iso8601.

Having had to work with servers in 5 timezones myself, I can highly recommend going for UTC timestamps. With daylight savings not starting at the same time keeping track of what CET (or CEST) is in PST (or is it already PDT) is a nightmare.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.