Wednesday, August 22, 2012

Bash script to stop and disable list of services in Linux

# Defining List of unwanted services
SERVICES="rhnsd sendmail cups netfs autofs nfslock mdmonitor isdn cpuspeed rpcidmapd rpcgssd iptables xfs pcmcia smartd"

# Finding each service status
for service in $SERVICES; do
  if [ -f /etc/init.d/$service ]; then
     # Turning off the service
      chkconfig $service off
     if_running=`service $service status | egrep -i running`
      # Stopping the service if it is running
      [ ! -z "$if_running" ] && service $service stop
  fi
done

No comments:

Post a Comment

Popular Posts

About Me

My photo
The intent of this blog is to share my work experience and spread some smart solutions on Linux to System Administrators. I'm hoping the solutions shared in this Blog would be helpful and come as a handy for Viewers. Brief about me: I have 18+ years work experience in System and Cloud Administration domain, primarily works on VMware Cloud Products (vSphere, vCloud Director, vRealize Automation, NSX Adv. Load Balancer, vROps).