mercredi 6 septembre 2017

if condition getting executed even though the condition is not satisfied

Whats wrong in my script?

im trying to start the oracle listener & a service which uses a java process.

But if condition getting executed even though the condition is not satisfied...(i.e) when value of this is (ps -ef | grep -v root | grep LISTENER | wc -l) is 1 (listener is running) , if condition alone executing. below is the code

#!/bin/bash

mydate=date --rfc-3339=seconds logFile=/home/user/Pictures/ostart.log service=oatxpress service1=listener

if [[ $(ps -ef | grep -v root | grep LISTENER | wc -l) -eq 0 ]] && [[ $(ps -ef | grep -v grep | grep java | wc -l) -eq 0 ]]; echo "$(ps -ef | grep -v root | grep LISTENER | wc -l)" >>$logFile echo "$mydate : $service1 and $service is not running!!!" >>$logFile then lsnrctl start service oatxpress start echo "$mydate : $service1 and $service is started via script!!!" >>$logFile

elif [ $(ps -ef | grep -v root | grep LISTENER | wc -l) -eq 0 ]; echo "$mydate : $service1 is not running!!!" >>$logFile then lsnrctl start echo "$mydate : $service1 is started via script!!!" >>$logFile

elif [ $(ps -ef | grep -v root | grep java | wc -l) -eq 0 ]; echo "$mydate : $service is not running!!!" >>$logFile then service oatxpress start echo "$mydate : $service is started via script!!!" >>$logFile

else echo "$mydate : $service & $service1 are running!!!" >>$logFile fi }

Aucun commentaire:

Enregistrer un commentaire