This blog post is a linux study note, only for learning.
Learning blog address: click to open the link
==================================================
Today, in the process of reading the shell script to monitor the tomcat shutdown and automatic restart, I saw a curl command as follows
curl -s -o $GetPageInfo -m 10 --connect-timeout 10 $WebUrl -w %{http_code}
The specific function is to access the page and save the page content and return the status code.
The parameter functions are as follows:
-s --silent silent mode, that is, do not display errors and progress
-o $GetPageInfo save the file locally and name it $GetPageInfo
-m indicates the maximum time to fetch a web page (maximum allowable time for data transfer)
-m 10 means that if the operation of obtaining the source code of the webpage cannot be completed within 10 seconds, give up
--connect-timeout connection timeout
--connect-timeout 10 means give up if it can't connect within 10 seconds
$WebUrl is the page path variable we want to visit
-w The -w parameter of curl we can customize the output of curl, %{http_code} represents the http status code
Tried to use it
curl -s http://www.baidu.com -w %{http_code}
command, the return result is as follows