Write bash shell to check the status of all services which are running/stopped in Linux?

Ans :

#Created on:02-02-2011 
#Last modified:02-02-2011 
#Purpose:To Check the status of services 
#Author:Surendra Kumar Anne 
#The below for loop will take inputs from chkconfig command to check the services which are running/stoped on the machine. 
for i in `chkconfig --list | awk '{print $1}' | grep -v :`
do 
/sbin/service $i status 
done

This script will take services names from checkconfig command and execute service command on that service.

Update:Recently I came to know that there is a command which you can right away use to list all the services which are in running or stopped status

In Ubuntu

initctl list

In Redhat based:

#service --status-all
The following two tabs change content below.
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.