Formatting uptime
Hello everyone.
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? |
cat /proc/uptime
The first field is the time since boot, the second is total idle time. |
Quote:
Thanks. --- rod. |
Quote:
|
Quote:
Quote:
|
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.
|
if you don't want to find through /proc, you can do a "poor man"'s one. like doing your own calculations,
Code:
#!/bin/sh |
Hi.
Quote:
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 |
All times are GMT -5. The time now is 10:50 AM. |