Linux script with curl to check webservice is up

后端 未结 6 838
难免孤独
难免孤独 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:39

    curl -sL -w "%{http_code}\\n" "http://www.google.com/" -o /dev/null
    
    • -s = Silent cURL's output
    • -L = Follow redirects
    • -w = Custom output format
    • -o = Redirects the HTML output to /dev/null

    Example:

    [~]$ curl -sL -w "%{http_code}\\n" "http://www.google.com/" -o /dev/null
    200
    

    I would probably remove the \\n if I were to capture the output.

提交回复
热议问题