Unix Programming - portable way to determine uptime?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2004 > portable way to determine uptime?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author portable way to determine uptime?
Aaron Walker

2004-01-23, 5:06 pm

I am writing a simple program that keeps track of a system's best
uptime, and was wondering if there was a portable way of determining the
uptime? I have already implemented the program in C using the linux
sysinfo() sys call (you could also just read /proc/uptime, but that
certainly isn't portable either), but this just plain annoys me. I'm
sure I will be the only person that uses this proggie, and I doubt I
would ever use it on my non-linux box (FreeBSD), but like I said it
still annoys me that it's not portable Any suggestions?

Thanks,
Aaron
--
/usr/bin/fortune says:
knowledge, n.:
Things you believe.

Morris Dovey

2004-01-23, 5:06 pm

Aaron Walker wrote:
quote:

> I am writing a simple program that keeps track of a system's best
> uptime, and was wondering if there was a portable way of determining the
> uptime? I have already implemented the program in C using the linux
> sysinfo() sys call (you could also just read /proc/uptime, but that
> certainly isn't portable either), but this just plain annoys me. I'm
> sure I will be the only person that uses this proggie, and I doubt I
> would ever use it on my non-linux box (FreeBSD), but like I said it
> still annoys me that it's not portable Any suggestions?



A program invoked only at boot time that writes the current date
and time into a file with permissions set to allow everyone to read?

--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c
Read my lips: The apple doesn't fall far from the tree.

Aaron Walker

2004-01-23, 5:06 pm

Morris Dovey wrote:
quote:

> A program invoked only at boot time that writes the current date and
> time into a file with permissions set to allow everyone to read?
>



Yes that was so obviously simple that it's embarrasing. I don't know
why my mind was thinking so complex.

Aaron
--
/usr/bin/fortune says:
The future isn't what it used to be. (It never was.)

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com