2
2
How I can get the system uptime in milliseconds from the Windows command line? I want something like the result of this function: gettickcount()
, e.g. 24233241231
.
Is there a command, utility or trick for this?
2
2
How I can get the system uptime in milliseconds from the Windows command line? I want something like the result of this function: gettickcount()
, e.g. 24233241231
.
Is there a command, utility or trick for this?
5
You`re sure that you want the milliseconds via command line utility. IMHO the overhead starting a new process to fetch this will take a little bit to long.
If seconds also fits your requirements, here is a little outline to get with some bash code.
The further assumption is that you have some kind of unix. This example works on a current linux system.
# Reading the time of boot
bootTime=$(awk '/^btime/{print $2;}' </proc/stat)
currentTime=$(date +%s)
liveTime=$(( ${currentTime} - ${bootTime} ))
echo "online since: ${liveTime}"
what about Windows? – ayyob khademi – 2013-03-13T18:31:13.607
1@ayyobkhademi: Parsing this line is a huge pain from the Windows command line, but you could use this as a source: systeminfo /FO list | findstr /C:"System Boot Time:"
. – Marcks Thomas – 2013-03-13T21:25:32.020
1
For windows, execute the following text in command line: net stats srv
9What operating system is this for? – Dave – 2013-03-13T11:33:19.140
1@MarcksThomas I don't see the problem here, there is nothing wrong with adding requirements afterwards, being the OP... – BloodPhilia – 2013-03-13T22:50:42.707
1It is not up to other users to change the nature of the question so radically as to no longer reflect the OP's problem. What more users started posting Linux solutions? That wouldn't help the OP at all. – BloodPhilia – 2013-03-13T22:58:10.440
@H.-DirkSchmitt Except this isn't a restaurant, it's a place where people come for help. If you're just in it for the reputation, I feel you're in it for all the wrong reasons. I haven't flagged your answer for deletion of whatever. And although it's true that a non-OP user edited the question, he has done so to reflect the wishes and requirements of the OP. If you want to debate this, feel free to join me in chat. – BloodPhilia – 2013-03-13T23:02:17.160
@H.-DirkSchmitt: I've opened a question on meta for this discussion.
– Marcks Thomas – 2013-03-13T23:08:30.3471@H.-DirkSchmitt: Frankly, I think the answer has merit, at least until we reach a consensus on meta. – Marcks Thomas – 2013-03-13T23:31:17.047
@ayyobkhademi: AFAIK on Windows it's not easy to get the uptime value in ms from the command line. The closest you can come to it I believe is calling a PowerShell script that in turn invokes GetTickCount() or better still GetTickCount64() (Vista+ only) from Kernel32.dll – Karan – 2013-03-13T23:50:11.687