In this post we will read about curl command to check the http status. cURL is a computer software project providing a library and command-line tool for transferring data using various protocols. The cURL project produces two products, libcurl and cURL.
libcurl is a free client-side URL transfer library, supporting FTP, FTPS, Gopher, HTTP, HTTPS, SCP, SFTP, TFTP, Telnet, DICT, the file URI scheme, LDAP, LDAPS, IMAP, POP3, SMTP and RTSP.
curl is a command line tool for getting or sending files using URL syntax.
curl is widely used for checking the staus of URL.
Because it is in command line it is very helpful to system admins and programmer.
I will show you two simple method to check the status of URL.
(1) This is simple method but it shows you the content of URL as well.
(2) : To only check the status of URL with its header information.
curl -Is https://sharadchhetri.com
Here, -I = Fetch the HTTP-header only
-s = Silent or quiet mode. Don’t show progress meter or error messages. Makes Curl mute.
Note: With the help of the second method you can create a nagios plugin which do not need to install in client server.
sharad@localhost:/tmp$ curl -Is https://sharadchhetri.com | grep HTTP | cut -d ' ' -f2 200 sharad@localhost:/tmp$ Here 200 status mean website is running fine