get http status code in bash script wit curl

A simple piece of bash to know if your service is up or not

response=$(
    curl YOUR_URL \
        --write-out %{http_code} \
        --silent \
        --output /dev/null \
)
test "$response" -ge 200 && test "$response" -le 299

You can replace the test by whatever suits you of course

Search
Recent Posts
categories
Support This Site

If my blog was helpful to you, then please consider visiting my Amazon Wishlist or donating via Paypal or Square Cash