Sponsored Content
Full Discussion: Uptime
Top Forums UNIX for Dummies Questions & Answers Uptime Post 302221093 by MastaFue on Sunday 3rd of August 2008 10:43:55 AM
Old 08-03-2008
alright here is a working solution I found (since I am only answering myself^^) if anybody is interested:

Code:
uptime | sed 's/.*up \(.*\),.*user.*/\1/' | awk  '{sub(":", " hours ", $0);  sub(" mins", " min", $0); sub(" secs", " sec", $0); sub("hrs", "hours", $0); sub(",", "", $0); print "uptime: " $0 " min"}' | awk ' {sub( "min min", "min", $0); sub( "hours min", "hours", $0); sub( "secs min", "sec", $0);  sub( "day min", "day", $0);  sub( "days min", "days", $0); print  $0}'


here is a short explanation: the second awk is there to get rid of unwanted output like secmin, minsmin, hoursmin etc.
so with two awk commands I got my desired output which looks like this

uptime: 3 days 9 hours 29 min
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

uptime

Hi Folks uptime 12:24pm up 2 days, 3:12, 4 users, load average: 0.00, 0.00, 0.00 what does the load average figure mean.. regards Hrishy (2 Replies)
Discussion started by: xiamin
2 Replies

2. UNIX for Dummies Questions & Answers

Getting uptime

I'm trying to get the uptime of my computer (Mac OS X) and I can go into the terminal and type "uptime" OK, and that gives me a string with the uptime in it. The problem is that the string changes a lot, and its very difficult to get the data I'm trying to extract out cleanly. Now I have 3... (2 Replies)
Discussion started by: Freefall
2 Replies

3. UNIX for Dummies Questions & Answers

uptime

On HP-UX, the 13th argument of uptime is sometime the load and sometime the word AVERAGE:??? 14 Jun 06 5:00pm up 44 days, 54 mins, 0 users, load average: 0.00, 0.02, 0.03 14 Jun 06 5:15pm up 44 days, 1:09, 0 users, load average: 0.00, 0.01, 0.01 When the time is in minutes, then the load... (1 Reply)
Discussion started by: qfwfq
1 Replies

4. AIX

HMC uptime

Hey guys!! Was tring to figure out how to find the uptime of an HMC? Any clue Bala (2 Replies)
Discussion started by: balaji_prk
2 Replies

5. Solaris

having problem with uptime.

HI All, I have problem with "uptime" on one of the sun server.(SunOS 5.9 Generic_118558-11 sun4u sparc SUNW,Sun-Fire-V240).when i am issuing uptime command its not showing uptime.even its not showing output for who -b. $ uptime 11:01am 1 user, load average: 0.06, 0.04, 0.03 $ who -b $... (3 Replies)
Discussion started by: jeevanbv
3 Replies

6. AIX

Hmc uptime

HELLO ALL HOW CAN I CHECK HMC UPTIME :confused: :confused: VERSION 6 :D (7 Replies)
Discussion started by: kalaso
7 Replies

7. Shell Programming and Scripting

Process Uptime

Hi, I need some help about a script i need to write. I want to check , if some specific process, are running since 2 hours. I tried to use a loop , grep my pid and use find -ctime on /proc directory, to list what i need. for i in `ps -ef |grep process |grep -v grep|awk '{print $2}'`... (2 Replies)
Discussion started by: rokerij
2 Replies

8. Linux

uptime options

Hi All is there a way that i can return uptime if the machine has been on for longer than 4 days thanks ab (3 Replies)
Discussion started by: ab52
3 Replies

9. Shell Programming and Scripting

Extract the uptime from the output of the uptime command

Hi! I want to extract the uptime from the output of the uptime command. The output: 11:53 up 3:02, 2 users, load averages: 0,32 0,34 0,43 I just need the "3:02" part. How can I do this? Dirk (6 Replies)
Discussion started by: Dirk Einecke
6 Replies

10. War Stories

Once upon an uptime.

Hi All, Having recently started a new job, a Data Center Migration in fact I have been tasked with looking at some of the older Solaris boxes when I came across this little gem. nismas# uname -a SunOS nismas 5.5.1 Generic_103640-27 sun4u sparc SUNW,Ultra-1 nismas# uptime 10:37am up 2900... (2 Replies)
Discussion started by: gull04
2 Replies
MIN(3)									 1								    MIN(3)

min - Find lowest value

SYNOPSIS
mixed min (array $values) DESCRIPTION
mixed min (mixed $value1, mixed $value2, [mixed $...]) If the first and only parameter is an array, min(3) returns the lowest value in that array. If at least two parameters are provided, min(3) returns the smallest of these values. Note Values of different types will be compared using the standard comparison rules. For instance, a non-numeric string will be com- pared to an integer as though it were 0, but multiple string values will be compared alphanumerically. The actual value returned will be of the original type with no conversion applied. PARAMETERS
o $values - An array containing the values. o $value1 - Any comparable value. o $value2 - Any comparable value. o $... - Any comparable value. RETURN VALUES
min(3) returns the parameter value considered "lowest" according to standard comparisons. If multiple values of different types evaluate as equal (e.g. 0 and 'abc') the first provided to the function will be returned. EXAMPLES
Example #1 Example uses of min(3) <?php echo min(2, 3, 1, 6, 7); // 1 echo min(array(2, 4, 5)); // 2 // The string 'hello' when compared to an int is treated as 0 // Since the two values are equal, the order they are provided determines the result echo min(0, 'hello'); // 0 echo min('hello', 0); // hello // Here we are comparing -1 < 0, so -1 is the lowest value echo min('hello', -1); // -1 // With multiple arrays of different lengths, min returns the shortest $val = min(array(2, 2, 2), array(1, 1, 1, 1)); // array(2, 2, 2) // Multiple arrays of the same length are compared from left to right // so in our example: 2 == 2, but 4 < 5 $val = min(array(2, 4, 8), array(2, 5, 1)); // array(2, 4, 8) // If both an array and non-array are given, the array is never returned // as comparisons treat arrays as greater than any other value $val = min('string', array(2, 5, 7), 42); // string // If one argument is NULL or a boolean, it will be compared against // other values using the rule FALSE < TRUE regardless of the other types involved // In the below examples, both -10 and 10 are treated as TRUE in the comparison $val = min(-10, FALSE, 10); // FALSE $val = min(-10, NULL, 10); // NULL // 0, on the other hand, is treated as FALSE, so is "lower than" TRUE $val = min(0, TRUE); // 0 ?> SEE ALSO
max(3), count(3). PHP Documentation Group MIN(3)
All times are GMT -4. The time now is 04:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy