Page 1 of 1

Uptime

PostPosted: Tue Jun 24, 2003 2:27 pm
by Tux
How would I write a script that takes the output of the 'uptime' command and cuts out everything but the uptime. ie gets rid of load averages and current time etc

Advance Thanks (Sorry for the n00bish question)

PostPosted: Tue Jun 24, 2003 2:42 pm
by Void Main
To get what I have on the front page from the uptime command I do:

Code: Select all
uptime | tr -s ' ' | cut -f3-7 -d' ' | cut -f1-2 -d','


which gives me this:

up 506 days, 1:09


Not sure if that's how you want it, if not you should get the idea...

PostPosted: Tue Jun 24, 2003 2:57 pm
by Tux
I do indeed, as usual, top advice :D

PostPosted: Tue Jun 24, 2003 3:13 pm
by Void Main
Or you could have done something like:

Code: Select all
echo "scale=2;`cut -f1 -d' ' /proc/uptime`/60/60/24" | bc