News:

Happy New Year! Yes, the current one, not a previous one; this is a new post, we swear!

Main Menu

Uptimes!

Started by Sidoh, January 03, 2006, 02:03:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Joe

QuoteC:\Program Files\Microsoft Visual Studio\MyProjects\uptime\Debug>uptime
System uptime: 2 days, 13 hours, 18 minutes, 12.46 seconds.

#include "stdafx.h"
#include "windows.h"

int main(int argc, char* argv[])
{
int miliseconds, seconds, minutes, hours, days;
miliseconds = GetTickCount();
seconds = miliseconds / (1000); seconds = seconds % 60;
minutes = miliseconds / (1000 * 60); minutes = minutes % 60;
hours   = miliseconds / (1000 * 60 * 60); hours   = hours % 24;
days    = miliseconds / (1000 * 60 * 60 * 24);
miliseconds = miliseconds % 100;

printf("System uptime: ");
printf("%u", days);        printf(" days, ");
printf("%u", hours);       printf(" hours, ");
printf("%u", minutes);     printf(" minutes, ");
printf("%u", seconds);     printf(".");
printf("%u", miliseconds); printf(" seconds.");

return 0;
}
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


zorm

Quote from: Joe[e2] on January 03, 2006, 05:50:15 PM
QuoteC:\Program Files\Microsoft Visual Studio\MyProjects\uptime\Debug>uptime
System uptime: 2 days, 13 hours, 18 minutes, 12.46 seconds.

#include "stdafx.h"
#include "windows.h"

int main(int argc, char* argv[])
{
int miliseconds, seconds, minutes, hours, days;
miliseconds = GetTickCount();
seconds = miliseconds / (1000); seconds = seconds % 60;
minutes = miliseconds / (1000 * 60); minutes = minutes % 60;
hours   = miliseconds / (1000 * 60 * 60); hours   = hours % 24;
days    = miliseconds / (1000 * 60 * 60 * 24);
miliseconds = miliseconds % 100;

printf("System uptime: ");
printf("%u", days);        printf(" days, ");
printf("%u", hours);       printf(" hours, ");
printf("%u", minutes);     printf(" minutes, ");
printf("%u", seconds);     printf(".");
printf("%u", miliseconds); printf(" seconds.");

return 0;
}


That sucks because it will wrap at 49.7 days IIRC. Fix.
"Frustra fit per plura quod potest fieri per pauciora"
- William of Ockham

iago

Quote from: zorm on January 03, 2006, 06:10:06 PM
Quote from: Joe[e2] on January 03, 2006, 05:50:15 PM
QuoteC:\Program Files\Microsoft Visual Studio\MyProjects\uptime\Debug>uptime
System uptime: 2 days, 13 hours, 18 minutes, 12.46 seconds.

#include "stdafx.h"
#include "windows.h"

int main(int argc, char* argv[])
{
int miliseconds, seconds, minutes, hours, days;
miliseconds = GetTickCount();
seconds = miliseconds / (1000); seconds = seconds % 60;
minutes = miliseconds / (1000 * 60); minutes = minutes % 60;
hours   = miliseconds / (1000 * 60 * 60); hours   = hours % 24;
days    = miliseconds / (1000 * 60 * 60 * 24);
miliseconds = miliseconds % 100;

printf("System uptime: ");
printf("%u", days);        printf(" days, ");
printf("%u", hours);       printf(" hours, ");
printf("%u", minutes);     printf(" minutes, ");
printf("%u", seconds);     printf(".");
printf("%u", miliseconds); printf(" seconds.");

return 0;
}


That sucks because it will wrap at 49.7 days IIRC. Fix.

Is there actually a way to get proper uptime on Windows?

zorm

Yes, using QueryPerformanceFrequency and QueryPerformanceCounter.
"Frustra fit per plura quod potest fieri per pauciora"
- William of Ockham

MyndFyre

The biggest uptime I ever recall seeing on my computers was 84 days+.  I usually notice uptime when I'm checking my network connections for functionality (the window displays connection uptime which is at longest the computer's uptime.
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

Ergot

Quote from: Sidoh on January 03, 2006, 03:38:46 PM
Ironically, there was a power outage last night. :(
Pwned :( Did you save your essay :O?
Quote from: Newby on February 26, 2006, 12:16:58 AM
Who gives a damn? I fuck sheep all the time.
Quote from: rabbit on December 11, 2005, 01:05:35 PM
And yes, male both ends.  There are a couple lesbians that need a two-ended dildo...My router just refuses to wear a strap-on.
(05:55:03) JoE ThE oDD: omfg good job i got a boner thinkin bout them chinese bitches
(17:54:15) Sidoh: I love cosmetology

Sidoh

Quote from: MyndFyrex86] link=topic=4438.msg48789#msg48789 date=1136331010]
The biggest uptime I ever recall seeing on my computers was 84 days+.  I usually notice uptime when I'm checking my network connections for functionality (the window displays connection uptime which is at longest the computer's uptime.

Hehe, that's how I check on Windows too.

Quote from: Ergot on January 03, 2006, 06:35:03 PM
Pwned :( Did you save your essay :O?

I did! :)

MyndFyre

Quote from: Sidoh on January 03, 2006, 07:13:10 PM
Quote from: MyndFyrex86] link=topic=4438.msg48789#msg48789 date=1136331010]
The biggest uptime I ever recall seeing on my computers was 84 days+.  I usually notice uptime when I'm checking my network connections for functionality (the window displays connection uptime which is at longest the computer's uptime.

Hehe, that's how I check on Windows too.

Psh... who said anything about Windows?














OK, ok, I can't imagine going 84 days on Linux.  :o
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

Quik

Turned off my Linux server the other day for a day, before that it had 5 or 6 weeks going.
Quote[20:21:13] xar: i was just thinking about the time iago came over here and we made this huge bomb and light up the sky for 6 min
[20:21:15] xar: that was funny

Sidoh

Haha, I noticed deepthought is running quite a bit faster after the restart, even if it was accidental/unwanted. :)

igimo1

System uptime: 2 days, 18 hours, 14 minutes, 38 seconds, and 828 milliseconds.

skip

System uptime 15 days, 4 hours, 7 minutes and 32 seconds, connection uptime 3 days, 1 hours, 23 minutes and 49 seconds.

rabbit

LILI: [20:32:50.204] Computer Time: 13 days, 10 hours, 41 minutes, 31 seconds
Attic: [20:36:40.311] Computer Time: 24 minutes, 21 seconds
Paradise: Off
Laptop: Off

iago

Quote from: MyndFyrex86] link=topic=4438.msg48801#msg48801 date=1136334464]
Quote from: Sidoh on January 03, 2006, 07:13:10 PM
Quote from: MyndFyrex86] link=topic=4438.msg48789#msg48789 date=1136331010]
The biggest uptime I ever recall seeing on my computers was 84 days+.  I usually notice uptime when I'm checking my network connections for functionality (the window displays connection uptime which is at longest the computer's uptime.

Hehe, that's how I check on Windows too.

Psh... who said anything about Windows?

I don't think any other OS would require such a kludge. 

It's the same idea as finding a host's ip by pinging them.. stuff like that bugs me :)

MyndFyre

Quote from: iago on January 03, 2006, 10:05:05 PM
I don't think any other OS would require such a kludge. 
Note that I didn't say I would *check* it that way, I said I'd *notice* it.
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.