Uptime

Place to discuss anything, almost. No politics, religion, Microsoft, or anything else that I (the nazi censor) deem inappropriate.

Uptime

Postby Tux » Tue Jun 24, 2003 2:27 pm

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)
Tux
guru
guru
 
Posts: 689
Joined: Wed Jan 08, 2003 10:40 am

Postby Void Main » Tue Jun 24, 2003 2:42 pm

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...
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby Tux » Tue Jun 24, 2003 2:57 pm

I do indeed, as usual, top advice :D
Tux
guru
guru
 
Posts: 689
Joined: Wed Jan 08, 2003 10:40 am

Postby Void Main » Tue Jun 24, 2003 3:13 pm

Or you could have done something like:

Code: Select all
echo "scale=2;`cut -f1 -d' ' /proc/uptime`/60/60/24" | bc
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA


Return to The Lounge

Who is online

Users browsing this forum: No registered users and 1 guest

cron