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
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
- Anisble: ERROR! unexpected parameter type in action:
Fix - June 29, 2020 - FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018