How to get time synced outputs (different timezones on servers)

logssyslogtimetimezone

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?

Best Answer

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.

Related Question