/proc/uptime 'n' friends

In scripting languages and Java it is easier to read a file than to fork uptime and sysctl.

It all depends on your scripting language. In a Unix oriented scripting language e.g. In Ruby, Perl, various shell you just do `uptime` which is easier than reading a file IMO.

If you want to stick to Java you can use JRuby. It has all strengths and limits of Java. I used it seccessfully for a project.
Code:
$> jirb
irb(main):001:0> `uptime`
=> " 14:27:34 up 2 days,  3:23,  1 user,  load average: 0.23, 0.08, 0.06\n"
irb(main):002:0>

In Python it is a bit more verbose and It depends a lot on your Python release, see here: https://docs.python.org/3/library/subprocess.html

bye
 
Back
Top