07-28-2008
@perderabo
the command you used does not work either because you don't use the command uptime you use echo "0:19 up 10 mins, 2 users, load averages: 0,61 0,54 0,31" | sed 's/.*up \(.*\),.user.*/\1/'
and that command will always produce 10 mins as the uptime
and if I change it to
uptime | sed 's/.*up \(.*\),.*user.*/\1/'
the output is the following
-> 6:58
which is my current uptime! (thx so far)
but how do I replace the colon with 'h' and how do I insert a 'min' after the minutes?
And can someone explain this command sed 's/.*up \(.*\),.*user.*/\1/' to me?
Thanks a lot guys for the help! I appreciate it!
update:
my attempt at soving the problem looks like this
uptime | sed 's/.*up \(.*\),.*user.*/\1/' | awk '{sub(":", "h ", $0); sub(" ", "", $0); print "uptime:" $0}'
But I do not know how to insert a 'min' directly after the minutes and how I can get rid of the two white spaces in front of the ' xh' (x for the number of hours).
Last edited by MastaFue; 07-28-2008 at 02:31 AM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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
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
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
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
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
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
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
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
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
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
uptime(1) General Commands Manual uptime(1)
NAME
uptime, w - show how long system has been up and/or who is logged in and what they are doing
SYNOPSIS
[user]
[pset_list]]
[user]
[pset_list]]
DESCRIPTION
prints the current time, the length of time the system has been up, the number of users logged on to the system, and the average number of
jobs in the run queue over the last 1, 5, and 15 minutes for the active processors.
is linked to and prints the same output as displaying a summary of the current activity on the system.
Options
and recognize the following options:
Print the current time, the length of time the system has been up,
and the number of users logged on to the system in the first line of the output. The average number of jobs in the core over
the last 1, 5, and 15 minutes for the active processors is also printed.
When used with the option, the load averages for the processor sets (psets) are calculated on a core basis.
Suppress the first line and the heading line.
This option should not be used with the option. This option assumes the use of the option to
Use long output.
This option assumes the use of the option to
Print the current time, the length of time the system has been up, and
the number of users logged on to the system in the first line of the output. The load averages over the last 1, 5, and 15
minutes for the processor sets (psets) given in the command line, pset_list, are displayed in the subsequent lines. If no
arguments are given, the load averages are displayed for all the psets in the system.
If pset id of an empty pset is given in the command line, a corresponding message will be displayed. If the kernel does not
have the pset capability, gives an error. The option cannot be used along with other options except
Use the short form of output for displaying terminal information.
The terminal name is abbreviated, and the login time and CPU times are suppressed.
Print only the first line describing the overall state of the system.
This is the default for the command.
Print a summary of the current activity on the system for each user.
This is the default for the command.
EXAMPLES
The command:
produces text resembling the following:
depending upon the current status of the system.
The command:
gives the load average of all the psets in the system. If 0, 94, 95, and 97 are existing psets in the system, the output will look like
the following:
The command:
gives output which looks like the following if 94 and 95 are valid pset ids:
The command:
gives the load average of the system, producing output resembling the following:
The command:
gives the load average of all the psets in the system. If 0 and 1 are psets in the system, the output will look like the following:
AUTHOR
was developed by the University of California, Berkeley and HP.
SEE ALSO
mpctl(2), pset_ctl(2).
uptime(1)