Re: script to turn off services

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The service command only fails if the service you are testing is not there -- which means whenever you use service on an installed service (active or not) it should return 0. I think you should look for another way of determining whether or not the service is running, like checking for a file located in /var/lock/subsys, or checking for a process with ps.

- Josh

Bill Tangren wrote:
I am trying to write a script that will turn off unneeded services, but I am not having any luck. I have tried the following:


service bluetooth status > /dev/null 2>&1
EXITVALUE=$?
if [ $EXITVALUE == 0 ]; then
   service bluetooth stop
   chkconfig --level 345 bluetooth off
fi


This works if bluetooth is not installed, but not if it IS installed and already turned off. In that case, the service command returns zero and the if block is executed.

Does anyone know how to modify this script so that it will run (or tell me where I can learn how to modify it)?

Thanks!

Bill Tangren


--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux