Terminal "Uptime" command result seems incorrect on my Mac mini after latest macOS Sonoma update.

Hi,


After I upgraded to Sonoma 14.4, the output from the Terminal "uptime" command seems incorrect. Attached is a terminal session in which I first ran the "date" command to get the current date and time; then the "uptime" command to get the system uptime; and finally the "last reboot" command; to list the date and time of the last system boot. Since the last boot time was at 21:49 on March 7th, and I executed these commands in the morning of March 10th, I would have expected that the "uptime" results would have reported a system uptime of about 2 1/2 days, but instead, it's reporting an uptime of 23 hours, 24 minutes. This reported uptime seems random, as it's not consistent with, for example, the number of full uptime days being missing from the "uptime" report. I've used the "uptime" command often in the past to monitor my system uptime, so I'm familiar with its use, but I've never seen anything like this before. I tried rebooting my system, but that didn't fix the problem. Am I doing something wrong here, or might this be some sort of bug?


Thanks!


Ken




[Re-Titled by Moderator]

Mac mini, OS X 10.11

Posted on Mar 10, 2024 10:04 PM

Reply
Question marked as Top-ranking reply

Posted on Mar 19, 2024 9:17 AM

Until this is fixed, I found that the following Terminal command to get the correct non-sleep-adjusted uptime is more convenient than the documented "Apple Menu Item > System Settings > General > About > System Report > Software":


system_profiler SPSoftwareDataType -detailLevel mini


The up-arrow key can be used to recall this command in a newly-opened Terminal window.


Ken



20 replies
Question marked as Top-ranking reply

Mar 19, 2024 9:17 AM in response to Kenneth Hjulstrom

Until this is fixed, I found that the following Terminal command to get the correct non-sleep-adjusted uptime is more convenient than the documented "Apple Menu Item > System Settings > General > About > System Report > Software":


system_profiler SPSoftwareDataType -detailLevel mini


The up-arrow key can be used to recall this command in a newly-opened Terminal window.


Ken



Mar 26, 2024 8:35 AM in response to x_user

Hi x_user,


On my machine, it appears that the 14.4.1 update fixed the "uptime " problem. I have the "Prevent automatic sleeping when the display is off" disabled, and "Put hard disks to sleep when possible" enabled, just as in 14.4.0, so I'm assuming that my machine slept as I left it running overnight, and the "uptime" value agrees with the uptime shown in the system profiler results as well as in the System Software Overview display.


Ken




Mar 11, 2024 12:03 PM in response to Kenneth Hjulstrom

Kenneth Hjulstrom wrote:

Am I doing something wrong here, or might this be some sort of bug?

A little of both. You are wrong to rely on that "last reboot" command. Many of those system events aren't recording what you think they are. There is a "shutdown cause" that is totally meaningless. In this case, that "last reboot" is defined as:


The pseudo-user reboot logs in at reboots of the system, thus “last reboot” will give an indication of mean time between reboot.

Yeah. Right.


The system uptime is correct.

Mar 11, 2024 3:07 PM in response to etresoft

Hi etresoft,


I'll accept that the "last reboot" information might not be completely correct, but in my case, but in the attached screenshot, which shows the macOS date in the top menu bar, the system date, uptime data, and boot history in the Terminal window, and the uptime in the System Information window:


  1. The menu bar system date (1) and the the results of the "date" command (3) in the Terminal window match
  2. The "Time since boot" value (2) in the System Information window is consistent with the reported last reboot time (5) displayed by the "last reboot" command in the Terminal window (only off by one minute)
  3. The output of the "uptime" command (4) in the Terminal window differs significantly from the "Time since boot" value (2) in the System Information window. Doing the math, the "uptime" value would indicate that the system booted at 4:21 A.M. on March 11th, and there's no indication that this happened. What I'm guessing is happening is that the "uptime" command is now accessing an incorrect value somewhere in the system when calculating (incorrectly) the system uptime. I phoned Apple support earlier today to report this discrepancy, and they'll be looking into it.


In the meantime, I'm curious as to whether anyone else can reproduce this behavior.


Thanks,


Ken


Mar 12, 2024 7:49 AM in response to Kenneth Hjulstrom

Kenneth Hjulstrom wrote:

I'm curious as to whether anyone else can reproduce this behavior.

I cannot reproduce it on Ventura. Everything behaves as I would expect. The "last reboot" command consistently returns no output at all.


I only run Sonoma in a Virtual Machine. There, all of this information is unreliable. The "uptime" command seems to rely on the system clock time. The system clock time is, at least on my VM, totally unreliable. It seems like Sonoma only updates the time at system start up. This could be the result of a bug or security change. System certificates are tightly bound to system time. This may be an attempt to prevent malicious software from changing system time. Just a guess.


Certainly, my VM is going to result in unpredictable behaviour. But I've seen many reports of system time problems on Sonoma. What you are reporting seems to agree with my VM behaviour.


On Sonoma, I also get results from "last reboot". But because I'm running in a VM, I can easily get my VM time out of sync with system time. My "last reboot" results are then wildly incorrect. Some of your results also show a very long time between shutdown and reboot. It looks like the "reboot" values may be correct. But I definitely wouldn't trust any of the "shutdown" values.


So I agree that on Sonoma, "uptime" is not reliable. I still don't think "last reboot" is reliable. I will see if I can find a better source of truth.

Mar 16, 2024 1:31 PM in response to WirelessWAW

HI x_user,


Thanks for the detailed information. It now seems quite clear that the "uptime" command is no longer reporting the total elapsed time since the last reboot, but instead, only the "awake" time since the last reboot. What we don't know yet is whether this change was intentional or whether it's a bug. Personally, I'd consider this a bug, considering how the "uptime" command is generally understood on other Linux systems, though an interesting enhancement to the "uptime" command would be a parameter that could toggle the output between "total uptime" vs. "awake uptime".


Ken


Mar 12, 2024 9:36 AM in response to Matti Haveri

Hi Matti,


I think you might be right about this. I do have sleep enabled (my Energy Saver settings are attached), but in the case I reported on 11-Mar-24, the "boot" time that I calculated, 4:21 A.M. occurred about 1 1/2 hours after I left my computer and went to bed (I leave the computer running overnight, but turn off the power to the monitor). The 1.5 hour delay doesn't immediately correspond to the time I stopped using my computer, nor does it correspond to the delays I have for starting the screen saver (5 minutes) or for turning off the display (10 minutes), but it's possible that Sonoma was doing some sort of cleanup or other maintenance that might have kept the drive running for longer than the specified "before sleep" interval. When I started using my computer this morning, I ran the "uptime" command, and the uptime value appeared to be very similar to what it was when I left the machine last night. Unfortunately, I closed the Terminal app last night, so I don't have access to the actual uptime value that was reported last night. Tonight, I'll run "uptime" again right before leaving the computer for the evening, but I'll leave the Terminal session open, so I can easily compare tonight's "uptime" value with the one I'll get tomorrow morning.


Thanks,


Ken


Mar 13, 2024 9:01 PM in response to SoYoung24

Hi SoYoung24,


By chance, is the system drive in your iMac a spinning disk drive and not an SSD? I'm asking because I'm running my 2018 Mac Mini from an external spinning disk drive. From what I've read, the "Put hard drives to sleep when possible" setting in the "Energy Saver" settings only has an effect on spinning disk drives, and since others here have found a link between the "uptime" discrepancy and machine sleep durations, and since I believe that there are no current Macs for sale that use spinning disk drives, that it's possible that during testing for the 14.4 release, the "uptime" command broke and testing it with a spinning drive hosting macOS may not have been been part of Apple's test suite.


Ken

Mar 16, 2024 9:50 AM in response to Kenneth Hjulstrom

Similar issue on my Mac Pro M1...

uptime command shows:

mac-witek % uptime

 8:54 up 1 day, 7:01, 2 users, load averages: 1.10 1.53 1.95

mac-witek % uptime

17:41 up 1 day, 8:09, 2 users, load averages: 1.87 1.83 1.70

As you can see, despite that there are almost 9 hours between two executions of "uptime" command, there is only 1 hour of difference between results of these executions... and "Software Report" shows ... 7 days since the last reboot. This issue appears since I have updated MacOS to 14.4

Mar 30, 2024 8:43 AM in response to Kenneth Hjulstrom

Glad I'm not the only one experiencing this. 14.4.1 on an M1 Pro here. It seems like it must be resetting at some point. If it just thought it wasn't "up" while sleeping, it would still continue increasing, albeit more slowly. Monitoring further, but it seems like it stays usually less than a day of uptime, certainly not exceeding 2 days. Right now, last boot 3 days ago, reported uptime of ~23 hours.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Terminal "Uptime" command result seems incorrect on my Mac mini after latest macOS Sonoma update.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.