# [erlang-questions] Node uptime

Mazen Harake <>
Tue Mar 16 15:00:34 CET 2010

```Then I guess that the comment in overload.erl is wrong. I was actually
checking this when I realized that any part of the c code could have
made the wrap so I didn't bother checking...

But it still feels like the "wrong" place to find it... perhaps
erlang:uptime() would be a good alternative or whatever else then this
(make it more "user friendly" *shrug* :P)

Anyway, Thanks! In the end I don't care how to get the information as
long as I can get it fairly simple :)

/Mazen

On 16/03/2010 15:47, Chandru wrote:
> On 16 March 2010 13:25, Ulf Wiger<>  wrote:
>
>
>> On Tue, 16 Mar 2010 14:09:51 +0100, Håkan Huss<>  wrote:
>>
>>   Check out erlang:statistics(wall_clock).
>>
>>> /Håkan
>>>
>>>
>> statistics(wall_clock) wraps after ca 37 hours.
>>
>>
>> %% Mask equal to 2^27 - 1, used below.
>>
>> %% Returns number of milliseconds in the range [0, 2^27 - 1]. Must have
>> %% this since statistics(wall_clock) wraps. Having 2^27 -1 as the max
>> %% assures that we always get non-negative integers. 2^27 milliseconds
>> %% are approx. 37.28 hours.
>> get_now() ->
>>
>> This means that unless you get in from the start and continuously
>> sample statistics(wall_clock), it can't be relied upon.
>>
>>
>>
> Is that correct? Here is the output from one of our nodes.
>
> 34>  util:uptime().
> "55 days, 11 hours, 58 minutes and 3 seconds"
>
> 35>  erlang:statistics(wall_clock).
> {4795096445,13307}
>
> uptime/0 is implemented as:
> uptime() ->
>      {UpTime, _} = erlang:statistics(wall_clock),
>      {D, {H, M, S}} = calendar:seconds_to_daystime(UpTime div 1000),
>      lists:flatten(io_lib:format("~p days, ~p hours, ~p minutes and ~p
> seconds", [D,H,M,S])).
>
> cheers
> Chandru
>
>

---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com

```