I've been able to retrieve the uptime value from /proc/uptime
(which is in seconds). However, I need to retrieve the last boot time stamp using C. (I cannot use system(...)
function to call uptime.)
For example, when I run the uptime
command, the value I get is:
15:31:35 up 2 days, 4:14, 3 users, load average: 0.04, 0.05, 0.05
I need that first part: 15:31:35
. Is there a built-in C function that can get me this?
Open /proc/uptime
and read it. The first number is the uptime in seconds.