We're an ISO27001:2013 Certified Supplier

24 hour clock

Sometimes we just want it to be easier.

You find out that a server rebooted a few days ago, and you’d like to know why. It would be helpful to look at the logs just before the reboot, so let’s work out when it rebooted. The uptime command gives hints:

$ uptime
 13:24:52 up 2 days,  19:42,  6 users,  load average: 0.86, 0.97, 0.80

It’s been up for 2 days, 19 hours and 42 minutes, and it’s now 13:24, so it must have rebooted, er, hang on…

Trying that calculation with insufficient coffee is daunting – but there’s an easy fix. The uptime command has a --since option:

$ uptime --since
2018-03-03 17:42:57

How fabulous is that? How many times have you tried to do 24-hour arithmetic in your head to work out when a system booted?

Was This Helpful?

Let us know in the comments below.

3 thoughts on “Linux Tips: Uptime”

  1. Errr. Not sure what in fact this is telling us. I don’t see that as a “24” hour calculation from when ?

    Example..

    uptime
    result = 09:53:23 up 18 days, 10:51, 6 users, load average: 0.00, 0.00, 0.00

    And now ..
    date
    result = Tue 13 Mar 09:53:48 GMT 2018

    uptime –since 2018-03-10 12:00:00
    result = 2018-02-22 23:02:18

    Don’t see what it’s telling me, as clearly the system has been up OVER 24 hours 2018-03-10 12:00:00 … confused .. ??

    1. The result of your “uptime” command shows that, at 09:53:23, the system had been up for 18 days, 10 hours and 51 minutes. We can see from the subsequent “date” command that you ran the uptime command on Tuesday, 13th March.

      From that information, we can calculate when the system was booted. We simply need to go back in time 18 days, 10 hours and 51 minutes from 09:53 on 13th March – but that’s a non-trivial calculation, and is the “24 hour calculation” I referred to in the post.

      We can approximate: 10h51m before 09:53 is around llpm (23:00) the day before, so 12th March. 18 days before that is 6 days before the end of February, or 22nd February on this non-leap year. So the system booted around 23:00 on 22nd February.

      Much easier, though, is to simply type “uptime –since” (note that the –since option does not take any arguments), which tells us the system boot time was 2018-02-22 23:02:18. That confirms our estimate, and is, of course, much quicker, easier and more accurate than trying to do 24 hour maths.

Leave a Reply

Your email address will not be published. Required fields are marked *

Secure. Reliable. Scalable.

If that doesn't describe your current Linux systems, check out our FREE Linux Survival Guide to help you get your systems up to scratch today!

  • This field is for validation purposes and should be left unchanged.