I wanted to create a Linux script to check recursively if web service is up and if it is down then wait for sometime and check again.
I have written below script using curl
which will check whether web service is up and if yes it will echo message and same with fail.
test_command='curl -sL \
-w "%{http_code}\\n" \
"http://www.google.com:8080/" \
-o /dev/null \
--connect-timeout 3 \
--max-time 5'
if [ $(test_command) == "200" ] ;
then
echo "OK" ;
else
echo "KO" ;
fi
I am trying now to add recursive code in else part so that if web service is not yet up after deployment then it will add some wait in else part and will check the status again after some seconds for that web service.