About /proc/uptime

James Drabb JDrabb at tampabay.rr.com
Wed Sep 25 19:38:48 PDT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 25 Sep 2002 22:32:55 -0400
James Drabb <JDrabb at tampabay.rr.com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On Thu, 26 Sep 2002 00:32:54 +0200
> "T.B. van der Molen" <tbm at home.nl> wrote:
> 
> > Hi,
> > 
> > /proc/uptime contains two numbers. The first is the current uptime of 
> > the machine, but what's the second?
> > 
> > TYI
> > 
> > Tim
> > 
> > -- 
> > "Period Three Implies Chaos"
> > - T.Y. Li & J.A. Yorke (1975)
> > 
> > -- 
> > Unsubscribe: send email to listar at linuxfromscratch.org
> > and put 'unsubscribe lfs-chat' in the subject header of the message
> > 
> 
> You can take a look at /usr/src/linux-2.4.19/fs/proc/proc_misc.c to
> see how it is generated : )
> 
> From the code it appears to be the total accumulated idle time.
> 
> len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
>         uptime / HZ,
>         uptime % HZ,
>         idle / HZ,
>         idle % HZ);
> 
> Jim Drabb
> - -- 
> - ----------------------
> James Drabb, JR
> Programmer Analyst
> Davenport, FL
> JDrabb at tampabay.rr.com
> - ----------------------
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.7 (GNU/Linux)
> 
> iD8DBQE9knHXMSVDgbMHT7ERAiiuAJ42DePUP/7g+UwJZBuDpniUNheBugCgif8O
> W6OhNAZz6JRwOYO/+IAswiY=
> =PVU7
> -----END PGP SIGNATURE-----
> -- 
> Unsubscribe: send email to listar at linuxfromscratch.org
> and put 'unsubscribe lfs-chat' in the subject header of the message
> 

So the first number is uptime / 60 = mins
so you can do:
echo uptime is $((`cut -f1 -d' ' /proc/uptime | cut -f1 -d.` / 60)) mins

And the second number is idle / 60 = mins
echo uptime is $((`cut -f2 -d' ' /proc/uptime | cut -f1 -d.` / 60)) mins

Jim Drabb

- -- 
- ----------------------
James Drabb, JR
Programmer Analyst
Davenport, FL
JDrabb at tampabay.rr.com
- ----------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9knM4MSVDgbMHT7ERAvEvAJ9+H7C4hSySvWySh15Ar5EAWPJkuQCdGbvL
dhE8AaRYTb3f7tN489qNlaM=
=H0vF
-----END PGP SIGNATURE-----
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-chat' in the subject header of the message



More information about the lfs-chat mailing list