[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WHO Command not working

From: Bob Proulx
Subject: Re: WHO Command not working
Date: Thu, 5 Jul 2007 01:51:52 -0600
User-agent: Mutt/1.5.9i

Hello Subram,

Doguparthi, Subramanyam (OpenView SW) wrote:
>  Utmp file for system boot time is getting updated on RHEL system but
> not on SLES systems. Then I think its SLES who is not updating utmp file
> for system boot time.

Let me clarify.  The 'who' command does not update the utmp file.  The
'who' command simply reads that file and reports information from it.

As to why SLES is not recording the boottime I don't know.  That is
outside the scope of the 'who' command since 'who' does not write the
file but only reports it.

>  Initially we thought of using /proc/uptime to come to know about the
> time when the system got booted last. But when the system time is moved
> backward or forward, /proc/uptime cannot be used. I am looking for a
> source thru which I can get correct boot time even though system time is
> changed.

You say that when the system time changes that /proc/uptime cannot be
used.  Why not?  I do not see any problems with using it and don't see
how time changes would affect the seconds of uptime reported by the

Of course I have to wonder why the system time would be getting set
forward and backward.  That would certainly be considered abnormal.
Since the system clock should not normally be changed like that I
would probably fix that problem first and then address other issues

If you are trying to find the absolute time that a system was booted
and don't trust the logged system boot time then you can simply
subtract the uptime from the current time.  I believe that will
provide the time the system booted regardless of system clock time
changes.  This works unless the system sleeps or hibernates such as a
laptop might.  But for a desktop or server that never sleeps or
hibernates I believe that works.

  date -R -d @$(( $(date +%s) - $(awk -F. '{print$1}' /proc/uptime) ))

The first number in /proc/uptime is the number of seconds the system
has been running.  Subtracting it from the current time would yield
the time the kernel booted.  I did not test this extensively but on
first pass it seemed to work for me.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]