How long has a process has been running (uptime)

8

1

Situation

I have been running a process on my laptop doing some heavy processing for the last few days. Every night I hibernate my computer, and boot it up in the morning.

What I Seek

I'm looking for a way to determine how long this process has been running.

What I've Tried

  • Using PowerShell I was able to find the start time of my process.

    Get-Process | Select-Object id, starttime, name |Sort-Object name
    

    However this is just the start time. I would like to know how long my process has been actively running. Not the time since it began running.

    6/13/2014 9:15:43 AM -> NOW (6/24/2014 10:38:45 AM) = 11 Days 1 Hour 23 Minutes 0 Seconds.

  • Using Task Manager, under the Processes tab I've looked at the CPU Time column, which is useful, and probably give the best statistical number for "how much time it takes to run this program", it however is not how long the process has been running.

    363:47:35

Edit: I don't think I was very clear, that I know how to get the elapsed time since this process began, however that isn't the amount of time the process has been running because I hibernate my computer, which basically freezes it. So I'm roughly looking for elapsed time since beginning process minus time spent hibernating between now and when the process began.

BenVlodgi

Posted 2014-06-24T14:37:52.127

Reputation: 181

Because I'm not up to writing a full blown answer: Perfmon>Process Object>Elapsed Time Counter>Your Process Instance – joeqwerty – 2014-06-24T14:57:19.233

Here too: http://serverfault.com/a/543130/87017

– Pacerier – 2016-12-26T03:34:42.610

@Pacerier However, this won't account for the amount of time the computer was in hibernation since the process started. – BenVlodgi – 2016-12-27T08:02:33.433

Answers

7

In PowerShell:

PS C:\> New-TimeSpan -Start (get-process notepad).StartTime

Found this command on TechNet Blogs.

Cornelius

Posted 2014-06-24T14:37:52.127

Reputation: 2 524

This worked on my python.exe but not my erl.exe – VenomFangs – 2015-10-16T16:19:20.357

Has to run PowerShell as admin. – Jiahao Cai – 2019-05-31T15:11:49.190

0

(Get-Process | ft Name,@{label="Elapsed Time";expression={[System.Math]::Round(((Get-Date)-$_.StartTime).totalseconds)}})

Fazer87

Posted 2014-06-24T14:37:52.127

Reputation: 11 177

2More info would help readers. – harrymc – 2014-06-24T15:50:46.633