Linux script with curl to check webservice is up

后端 未结 6 861
难免孤独
难免孤独 2021-01-30 17:05

I have a webservice provided at http://localhost/test/testweb

I want to write a script to check if webservice is up with curl

If there a curl parame

6条回答
  •  爱一瞬间的悲伤
    2021-01-30 17:15

    I use:

    curl -f -s -I "http://example.com" &>/dev/null && echo OK || echo FAIL
    

    -f --fail Fail silently (no output at all) on HTTP errors
    -s --silent Silent mode
    -I --head Show document info only

    Note:
    depending on needs you can also remove the "-I" because in some cases you need to do a GET and not a HEAD

提交回复
热议问题