bash - daemon startup script reporting incorrect status -


i wanting use startup script calls iperf @ boot time can specify chkconfig utility , control iperf command line typical service if choose. here have far:

#!/bin/bash  # chkconfig: - 50 50 # description: iperf  daemon=/usr/bin/iperf service=iperf info=$(pidof /usr/bin/iperf)  case "$1" in       start)               $daemon -s -d               ;;       stop)               pidof $daemon | xargs kill -9               ;;       status)               if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))                             echo $daemon pid $info running!!!               else               echo $daemon not running!!!               fi               ;;       restart)               $daemon stop               $daemon start               ;;       *)               echo "usage: $0 {start|stop|status|restart}"               exit 1               ;; esac 

everything works fine far. can start , stop service using script. can add chkconfig no problems. have noticed if iperf not running, when use status command still returns running:

with running:

 # service iperf status /usr/bin/iperf pid 34828 running!!! 

without running:

# service iperf status /usr/bin/iperf pid running!!! 

to point have not been able figure out why happening. can help?

you checking saying:

if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 )) 

and run script with:

service iperf status 

so guess ps -ef | ... | grep iperf finds call of script. can check printing output of ps -ef | grep -v grep | grep $service.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -