question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prerequisites

Steps to reproduce

There is too much difference in the readings of the /usr/bin/uptime and the Get-Uptime cmdlet

 PS > uptime -p
up 2 days, 16 hours, 26 minutes
 
PS > (Get-Uptime).ToString()
1.13:45:12

Expected behavior

Expected equal values

Actual behavior

Different values

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.0-rc.1
PSEdition                      Core
GitCommitId                    7.3.0-rc.1
OS                             Linux 6.0.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 29 Oct 2022 14:08:39 +0000
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

up

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
SteveL-MSFTcommented, Nov 7, 2022

@iSazonov I tend to agree that this seems like a bug that should be fixed in .NET

1reaction
iSazonovcommented, Nov 5, 2022

Looking through the .NET source, they only use CLOCK_BOOTTIME to calculate the start time of processes and is not public. So it seems the best option is to P/Invoke the API on non-Windows.

This doesn’t work on all platforms.

Best option is to request new API in .Net System.Environment.Uptime. Until that, since it is not critical, we could add a workaround for Linux systems and use /proc/uptime.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Linux Uptime Command With Usage Examples
Uptime is a command that returns information about how long your system has been running together with the current time, number of users...
Read more >
Linux | Uptime command with examples
Uptime Command In Linux: It is used to find out how long the system is active (running). This command returns set of values...
Read more >
Introduction to Linux uptime
Linux uptime is an important metric that shows how long the system has been running or how much time has passed since the...
Read more >
Documenting system uptime in Linux | Enable Sysadmin
While the uptime command is simple, I think it's useful for displaying basic system information. It can answer questions regarding how long the ......
Read more >
How to Quickly Check the System Uptime on Linux
uptime is the default command you can use to check for how long your system has been running. It also provides information on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found