2

I have 2 servers, one is reporting uptime of 9 hours, the other 7 hours. I have no other monitoring system in place. My "hosting" provider says it was a single power spike event that rebooted both and that the uptime cannot be trusted to be accurate. Is there any way he is right? Can 2 servers rebooted the same time show uptime difference of 2 hours? Thanks.

evilpenguin
  • 781
  • 3
  • 9
  • 16
  • It *might* be possible if the date was off on one of them (and subsequently fixed by ntp running or something) - I'm not sure about the internals of how it stores the startup date/time. – ceejayoz Aug 10 '17 at 13:07
  • What does `last reboot` show? – ewwhite Aug 10 '17 at 20:12

2 Answers2

2

Can linux uptime value be trusted to pinpoint time of outage?

No.

/proc/uptime and/or the uptime command only tell you how long a system has been running, i.e. it allows you to determine how long since the system recovered from an outage.

Even if you don't have monitoring last -F reboot or a quick inspection of /var/log/messages will usually show you the time gap between the last recorded messages and the system recovering, allowing you to (roughly) estimate the duration of an outage.

Uptime is AFAIK a simple ever increasing kernel counter that is not influenced by date/time manipulations of the system clock. I.e. when you change timezones or change the system time/date with for instance NTP, the date command or manipulate an (incorrect) hardware clock with hwclock , that won't change the uptime counter.

If your systems have an uptime that differs by two hours and they suffered the same outage then the most obvious conclusion is recovery from that outage took an additional two hours for one of those systems...

There are numerous potentially perfectly valid reasons for that, by the way.

HBruijn
  • 77,029
  • 24
  • 135
  • 201
2

uptime is only valid if you want to know the time that the system has been running since the last startup, no more than that.

Instead, tuptime keep records of the system startup and shutdown events. It is helpful in showing anormal shutdowns, like those ones produced by power outages and hangs, because their report include if it was ok or bad under the End column:

$ tuptime -t
No.        Startup Date                                Uptime       Shutdown Date   End                                       Downtime

1     22:21:49 05/15/18             50 minutes and 44 seconds   23:12:33 05/15/18    OK                                     13 seconds
2     23:12:46 05/15/18                1 minute and 2 seconds   23:13:48 05/15/18    OK            18 hours, 57 minutes and 18 seconds
3     18:11:06 05/16/18              2 minutes and 34 seconds   18:13:40 05/16/18   BAD               1 hour, 48 minutes and 6 seconds
4     20:01:46 05/16/18     1 hour, 29 minutes and 30 seconds   21:31:15 05/16/18   BAD                      14 minutes and 31 seconds
5     21:45:47 05/16/18             19 minutes and 42 seconds   22:05:28 05/16/18    OK             21 hours, 7 minutes and 18 seconds
6     19:12:47 05/17/18               37 minutes and 1 second   19:49:47 05/17/18    OK                                     26 seconds
rfmoz
  • 772
  • 9
  • 15