ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am looking for a way to format *nix system uptimes into a machine friendly form.
Currently the uptime is displayed as:
.. up 1 day, 3:00, .. I need it to be in plain numerical form like 1620 (as in the number of seconds of uptime)
My first idea was just use a the ::hrSystemUptime.0 MIB but my boss stated not to use that. He wants me to toy around with formatting the uptime using the date command somehow..
Any suggestions?
Last edited by SamuelHenderson; 04-18-2007 at 04:08 PM.
I realize this is slightly off topic, but do you know of any online or other summary of what information exists in the /proc file system, and how to interpret it. I've looked around in the past, and never found any concise or complete explanation. Some stuff is fairly obvious, but a lot of it you can only guess what it means. I'm given to believe that it tends to change over time, and people are reluctant to document it for fear of locking in to something.
I realize this is slightly off topic, but do you know of any online or other summary of what information exists in the /proc file system, and how to interpret it. I've looked around in the past, and never found any concise or complete explanation. Some stuff is fairly obvious, but a lot of it you can only guess what it means. I'm given to believe that it tends to change over time, and people are reluctant to document it for fear of locking in to something.
Thanks.
--- rod.
The /proc filesystem is dependent on what kernel you use (linux vs. BSD vs. Solaris, etc.). For linux, rudimentary (and incomplete) /proc documentation can be found in the kernel source tree under Documentation/filesystems/proc.txt.
I realize this is slightly off topic, but do you know of any online or other summary of what information exists in the /proc file system, and how to interpret it. I've looked around in the past, and never found any concise or complete explanation. Some stuff is fairly obvious, but a lot of it you can only guess what it means. I'm given to believe that it tends to change over time, and people are reluctant to document it for fear of locking in to something.
A coworker who has been using Linux much longer than I havwe said the /proc was full of kernel messages and stuff like that. I did a bit of research on this to find out for myself as well. I found the following http://www.tuxfiles.org/linuxhelp/linuxdir.html]here:
Quote:
This is a special directory. Well, actually /proc is just a virtual directory, because it doesn't exist at all! It contains some info about the kernel itself. There's a bunch of numbered entries that correspond to all processes running on the system, and there are also named entries that permit access to the current configuration of the system. Many of these entries can be viewed.
You can't use date - convert the seconds of uptime to a broken down structure (struct tm) with gmtime() then call strftime() to format the result, which is what date uses - strftime honors the same format constants as does date.
To paraphrase the automobile ad of some years ago, "GNU/Linux date is not your father's date".
It looks like you can get seconds since the epoch. You can specify a specific date in place of the current date. Doing some arithmetic seems like it would provide an answer ... cheers, makyo
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.