1

I have an application with some id like application_2019xxxxxxxxxxxxx

I'm able to find it's statistics with command yarn application -status application_2019xxxxxxxxxxxxx which gives output in key-value format.

The issue here is some of the fields are not in human readable format, e.g. start time and end time of application are in unix epoch format. This is causing trouble in automation of script.

Can anyone please help how to get all values in human readable format ? Thanks in advance :)

amol_shaligram
  • 226
  • 1
  • 11

2 Answers2

2

There are many ways to convert that data into human readable format some of them are below:

mysql> select from_unixtime(floor(1517874876754/1000));
+------------------------------------------+
| from_unixtime(floor(1517874876754/1000)) |
+------------------------------------------+
| 2018-02-05 18:54:36                      |
+------------------------------------------+
1 row in set (0.00 sec)

$ awk '{print strftime("%c", ( 1517874876754 + 500 ) / 1000 )}'
Mon 05 Feb 2018 06:54:37 PM EST

$ date -d @$(  echo "(1517874876754+ 500) / 1000" | bc)
Mon Feb  5 18:54:37 EST 2018
Vin
  • 515
  • 3
  • 17
  • that's helpful :) but i'm looking for something which can print values directly in human readable format and avoiding extra lines of code for conversion. – amol_shaligram Mar 15 '19 at 03:02
  • @Vin I noticed you are doing two different calculation on mysql and awk/date. Is there a reason why to add 500 in value and then divide by 1000. Also why are we dividing it by 1000? Can you also provide some links where such tit-bits can be found. Thanks for the info. – Mudit Singal Mar 22 '19 at 12:04
  • @MuditSingal I'm glad you asked that question so let me clear your doubt .I am adding 500 in that epoch time `1517874876754+500` because I need it in EST time zone that value depends on the time zone if you are on a different time zone that value(500) will change accordingly. Moreover, I am dividing by 1000 coz I don't want the miliseconds if I don't divide it by 1000 the value would be `Monday, February 5, 2018 11:54:36.754 PM EST` hope you get it and here is the link where you can try different numbers and formats https://www.epochconverter.com/ – Vin Mar 22 '19 at 15:54
  • @Vin Since EST is lagging by 5hrs from UTC shouldn't the time in milliseconds be subtracted before conversion? I am converting using linux date cmd – Mudit Singal Mar 23 '19 at 15:48
0

Try this : perl -leprint \ scalar\ localtime\ epoch time

and date -d @ epoch time

Vin
  • 515
  • 3
  • 17
PBK
  • 1
  • 2