[SOLVED] Converting timestamps to human-readable?

This forum is dedicated to advanced help and support :

Ask here your questions about advanced usage of Mageia. For example you may post here all your questions about network and automated installs, complex server configurations, kernel tuning, creating your own Mageia mirrors, and all tasks likely to be touchy even for skilled users.

[SOLVED] Converting timestamps to human-readable?

Postby jaywalker » Mar 19th, '12, 03:23

More logs are turning up with decimal numbers instead of dates and times. Is there a slick way to filter a log and convert these numbers into something human-readable? I imagine I will have to make readable copies of the logs, but it would be great if the log could just be piped through it to the screen.

In the meantime I'm going to try to make myself a ready-reckoner in Calc.

Richard

UPDATE
I found a ready-reckoner on the web: http://www.onlineconversion.com/unix_time.htm
And I discovered
Code: Select all
date -d "@1331776887.470"

All I need now is to bash it into shape :D
Last edited by jaywalker on Mar 21st, '12, 01:21, edited 1 time in total.
jaywalker
 
Posts: 341
Joined: Nov 17th, '11, 02:38
Location: Belfast, Northern Ireland

Re: Converting timestamps to human-readable?

Postby doktor5000 » Mar 19th, '12, 07:50

Could you give an example for such a timestamp and where this is used?
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18054
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Converting timestamps to human-readable?

Postby jaywalker » Mar 19th, '12, 16:15

/var/log/ConsoleKit/history
/var/log/Xorg.0.log though here it is relative to, presumably, start of boot. That may take a bit more work than a simple filter, but then again, it is only once per boot.

Seems that is all. I got the impression there were more. Maybe there is some sort of clean-up activity we don't know about, or maybe I am just mistaken.
jaywalker
 
Posts: 341
Joined: Nov 17th, '11, 02:38
Location: Belfast, Northern Ireland

Re: Converting timestamps to human-readable?

Postby jaywalker » Mar 21st, '12, 01:21

Here's a solution for the /var/log/ConsoleKit/history log which works rather well.

First copy the file to your home directory and add a ".csv" suffix to the file name.
Next open LibreOffice Calc and use the Insert->Sheet from file... menu option to load your "csv" log.
The import wizard will split the log entries up into columns, and you can play with that if you like, but I didn't.
The important timestamp field will be column A.
To convert to a LibreOffice date value use this formula in column B
Code: Select all
=25569+(A1/86400)

Now all you have to do is format the cell in B1 with this custom format string;
Code: Select all
use Format->Cells and click on the Numbers tab
select Category->User Defined
Type in format code; YYYY-MMM-DD HH:MM:SS.000

Now you can copy the B1 cell to all of the cells in column B in the range covered by the log.

I'm happy now.
jaywalker
 
Posts: 341
Joined: Nov 17th, '11, 02:38
Location: Belfast, Northern Ireland


Return to Advanced support

Who is online

Users browsing this forum: No registered users and 1 guest

cron