Getting the uptime of a SunOS UNIX box in seconds only

Posted by JF on Stack Overflow See other posts from Stack Overflow or by JF
Published on 2009-11-02T12:24:23Z Indexed on 2010/03/26 15:33 UTC
Read the original article Hit count: 489

Filed under:
|
|
|

How do I determine the uptime on a SunOS UNIX box in seconds only?

On Linux, I could simply cat /proc/uptime & take the first argument:

cat /proc/uptime | awk '{print $1}'

I'm trying to do the same on a SunOS UNIX box, but there is no /proc/uptime. There is an uptime command which presents the following output:

$ uptime
12:13pm  up 227 day(s), 15:14,  1 user,  load average: 0.05, 0.05, 0.05

I don't really want to have to write code to convert the date into seconds only & I'm sure someone must have had this requirement before but I have been unable to find anything on the internet.

Can anyone tell me how to get the uptime in just seconds?

TIA

© Stack Overflow or respective owner

Related posts about unix

Related posts about shell-scripting