LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-01-2009, 08:24 AM   #1
zodehala
Member
 
Registered: Nov 2008
Posts: 53

Rep: Reputation: 15
up time summerize


Code:
#uptime | grep "days"
21:23:25 up 4 days, 19:21,  2 users,  load average: 0.02, 0.01, 0.00
i wanna print just uptime days nt all details
 
Old 10-01-2009, 08:29 AM   #2
hank.classe@sungardhe.co
LQ Newbie
 
Registered: Apr 2009
Posts: 3

Rep: Reputation: 0
Solution

Learn to use piping. See example below:

[hclasse@malmodl1 ~]$ uptime
08:27:53 up 367 days, 31 min, 1 user, load average: 0.00, 0.00, 0.00
[hclasse@malmodl1 ~]$ uptime | awk '{print $3,$4}'
367 days,
[hclasse@malmodl1 ~]$
 
Old 10-01-2009, 08:30 AM   #3
fbianconi
Member
 
Registered: Apr 2008
Location: argentina
Distribution: Arch
Posts: 86

Rep: Reputation: 22
uptime | grep -o "[0-9]*\ days"
learn to use grep, see man pages.
 
Old 10-01-2009, 10:24 AM   #4
Ralfredo
LQ Newbie
 
Registered: Mar 2009
Posts: 17

Rep: Reputation: 0
Quote:
Originally Posted by zodehala View Post
i wanna print just uptime days nt all details
<NERD MODE ON>

Code:
awk '{printf "%2.2f days\n", $1/60/60/24}' /proc/uptime
 
Old 10-01-2009, 10:31 AM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 122Reputation: 122
Quote:
Originally Posted by Ralfredo View Post
<NERD MODE ON>

Code:
awk '{printf "%2.2f days\n", $1/60/60/24}' /proc/uptime
That's actually an elegant solution. No need to parse output, and would be useful for embedded devices where you don't have/want to have 'uptime'.
 
Old 10-01-2009, 01:09 PM   #6
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,078

Rep: Reputation: 195Reputation: 195
Quote:
Originally Posted by Ralfredo View Post
<NERD MODE ON>

Code:
awk '{printf "%2.2f days\n", $1/60/60/24}' /proc/uptime
Super nerdy

For anyone else wondering, as I saw, what the contents of /proc/uptime is, the first number is the total number of seconds the system has been up. The second number is how much of that time the machine has spent idle, in seconds.
 
Old 10-01-2009, 05:19 PM   #7
zodehala
Member
 
Registered: Nov 2008
Posts: 53

Original Poster
Rep: Reputation: 15
how can i list 2 service at the same time

chkconfig --list | grep mysqld && httpd
does not run
 
Old 10-01-2009, 07:03 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
That's a new qn; please start a new thread.
Thank you.

PS Try

chkconfig --list | grep -E mysql|http
 
Old 10-02-2009, 02:49 AM   #9
zodehala
Member
 
Registered: Nov 2008
Posts: 53

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by chrism01 View Post
That's a new qn; please start a new thread.
Thank you.

PS Try

chkconfig --list | grep -E mysql|http
Code:
[root@localhost ~]# chkconfig --list | grep -E mysqld|httpd
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
 
Old 10-02-2009, 11:20 AM   #10
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 122Reputation: 122
I think it should infact be:
Code:
chkconfig --list | grep -E 'mysql|httpd'
The quotes are needed so that the shell doesn't interpret the pipe.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting time and time zone altogether properly in Slack-current, KDE4 spaceballs Slackware 3 04-20-2011 06:15 AM
time on our RH linux FTP server is four hours ahead, but desktop time is correct?? dgr Linux - Newbie 10 10-09-2007 06:42 AM
System time vs Hardware time and Daylight Savings Time Toadman Linux - General 6 03-17-2007 09:12 AM
System time vs Hardware time and Daylight Savings Time Toadman Linux - Networking 6 03-16-2007 08:14 PM


All times are GMT -5. The time now is 09:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration