LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 11-12-2014, 11:59 PM   #1
vipinsqa
Member
 
Registered: Oct 2014
Posts: 40

Rep: Reputation: Disabled
List of services on Centos and corresponding packages.


Hi All,

I am using below script to get a list of all running services on my Centos box, corresponding package name and the install location.

for i in $(service --status-all | grep -E running\|stopped\|"not running" | awk '{print $1}');
do
echo "Service $i" >> $HOME/MyLog/running_$HOSTNAME.log;
rpm -qf /etc/init.d/$i >> $HOME/MyLog/running_$HOSTNAME.log;
rpm -ql $(rpm -qf /etc/init.d/$i) >> HOME/MyLog/running_$HOSTNAME.log;
done

This code snippet has a few problems. Though it lists all services, packages and install location in output log, I am not sure if the installed location given by rpm -ql is quite correct. It shows a lots of instal locations or files. I would need just the install location of the base package.
Also, if a service name if not found in /etc/init.d, the script throws a console output as well, which I dont want. Is there a way in a script where I can avoid the console output and errors? Anything which I can include in script for this?

Please revert if anyone has any clue on this.

Thanks.

Regards.
 
Old 11-13-2014, 04:18 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by vipinsqa View Post
I am not sure if the installed location given by rpm -ql is quite correct.
What do you mean "not quite correct"? The only way RPM packages can be installed in a different location is using %reloc. First of all not all packages accept that and secondly for an admin to do that would be exceptional...


Quote:
Originally Posted by vipinsqa View Post
Also, if a service name if not found in /etc/init.d, the script throws a console output as well, which I dont want.
Well then filter it out.


Quote:
Originally Posted by vipinsqa View Post
Is there a way in a script where I can avoid the console output and errors? Anything which I can include in script for this?
Not sure what you mean with this. Maybe give example output?
 
  


Reply



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
[SOLVED] Does installing update packages on RHEL and Centos will affecting running services? yohey03 Linux - Server 2 07-27-2014 12:19 AM
CentOS/RedHat: How to list all packages I installed via yum? sysbox Linux - Newbie 7 10-03-2013 02:21 PM
IS there a websight that list all packages available from the CentOS repositories? Knightron Red Hat 2 04-25-2012 03:23 PM
[SOLVED] List non-mandatory leaf packages [CentOS 5.4] carbonfiber Red Hat 2 02-21-2010 03:39 AM
Problem with packages - local list doesn't list all packages from a mirror simopal6 Debian 2 09-01-2008 04:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:01 AM.

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
Open Source Consulting | Domain Registration