In the below code, while loop is executing only one time whereas there are entry in crawler.cfg file.
when I am commmenting VAR=$(ssh ${HOSTS} ps ax | grep -v grep | grep $SERVICE|wc -l)
line in code then it is looping three times and working fine...
So, What is problem in this line?
Please assist.
while read crawler_info
do
PATH_OF_SERVER="/home/Crawler/"
THREAD_SCRIPT=crawler18.sh
HOSTS=$(echo $crawler_info|cut -d'|' -f1)
SERVICE="java"
VAR=$(ssh ${HOSTS} ps ax | grep -v grep | grep $SERVICE|wc -l)
if [ $VAR -ne 0 ]
then
echo "$SERVICE service running, everything is fine on ${HOSTS} node"
else
echo "java services is not running on ${HOSTS} node. process is triggering java services"
ssh ${HOSTS} ${PATH_OF_SERVER}${THREAD_SCRIPT} > /dev/null 2> /dev/null&
if [ $? -eq 0 ]
then
echo "java services triggered successfully on ${HOSTS} node"
else
echo "process is unable to trigger the java services on ${HOSTS} node"
fi
fi
done < crawler.cfg
crawler.cfg
n0007
n00011
n0000023