2

The intention of the following code is to check status of JBoss, the while loop iterates until the JBoss status comes to the 'DOWN' state. ` I have the following script, which I've set to this environment variable so that I can make use of it, vs the actual path to the script:

$ JBOSS_ROOT=/opt/app/jboss/jboss.sh
script
time=1
while  [ $JBOSS_ROOT status | egrep -nq "DOWN"  ]
  do
        echo "JBoss stooping, please wait ......."
        sleep 1m
        if [ $time -gt 6 ]
         then
            echo "Something went wrong.. it's been running more than 5 \
                minutes, please check JBoos server log and deployments"
            exit
        fi

        time=$(expr "$time" + 1)
  done

echo "JBoss stopped"
`
  • $JBOSS_ROOT status returns "JBoss DOWN" if JBoss in down (stop position).
  • $JBOSS_ROOT status returns "JBoss (pid:32627) is RUNNING" if JBoss is in running (start position).

Throwing error at while loop. saying that ./stop.sh: line 5: [: missing]'`.

1

You have your format wrong. Try this instead:

while  $JBOSS_ROOT status | grep -Enq "DOWN" 
do
    ...
done

The [ ] is not needed (and does not work) here. That's only for testing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.