tags:

views:

285

answers:

1

I'm writting a Perl script for which I need the uptime in seconds to do some calculation, in all the machine in the shop (i.e. linux, SunOS, and AIX). I have a way to get the uptime for linux (/proc/uptime), and SunOS (kstat -p unix:0:system_misc:boot_time), thanks to an another posting on this site, but I can find a good way of getting it for AIX. I don't really like the idea of parsing uptime with reg-ex, since uptime changes when the machine is been up just sec, mins, days, or over a year.

A: 

Parse the output of last(1)?

Find a file/directory that is only created/refreshed at boot time and stat it?

Frankly, using different regexs to handle the different possible outputs from uptime doesn't sound so bad.

mobrule