An Easy Way To Monitor A Website From Command Line In Linux

Monitor A Website From Command Line

Monitor A Website From Command Line In Linux

We all know that ping command will tell you instantly whether the website is live or down. Usually, we all check whether a website is up or down like below.

ping -c 3

Sample output:

PING ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=51 time=376 ms
64 bytes from ( icmp_seq=2 ttl=51 time=374 ms

--- ping statistics ---
3 packets transmitted, 2 received, 33% packet loss, time 2000ms
rtt min/avg/max/mdev = 374.828/375.471/376.114/0.643 ms

But, Would you run this command every time to check whether your website is live or down? You may create a script to check your website status at periodic intervals. But wait. It’s not necessary! Here is simple command that will watch or monitor on a regular interval.

watch -n 1 curl -I http://DOMAIN_NAME/

For those who don’t know, watch command is used to run any command on a particular intervals.


Let us check if site is live or down. To do so, run:

watch -n 1 curl -I

Sample output:

Every 1.0s: curl -I sk: Thu Dec 22 17:37:24 2016

% Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
 0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
HTTP/1.1 200 OK 
Date: Thu, 22 Dec 2016 12:07:09 GMT
Server: ApacheD
Vary: Cookieh
Link: <>; rel="", <https://w>; rel=shortlinki
Content-Type: text/html; charset=UTF-8

The above command will monitor our site at every one second interval. You can change the monitoring time as you wish. Unlike ping command, it will keep watching your site status until you stop it. To stop this command, press CTRL+C.

If you got HTTP/1.1 200 OK in the output, great? It means your website is working and live.

What about google?

watch -n 1 curl -I

Great! Google is working!

Facebook? Just run:

watch -n 1 curl -I

Well, Facebook is up and running too!

If it is your local website, you can cross check it by stopping your web server manually running the following commands,

If your website is running with nginx, run:

sudo systemctl stop ngix

If your website is using Apache, then you can stop as shown below.

sudo systemctl stop httpd

Now, go and check the command’s output. You will see connection refused error. Useful command, isn’t it?

This is a really handy one-liner command that you can use to monitor sites from Terminal. Also, It is quite useful when moving DNS or any other types of site migrations. It really comes in handy during high traffic events where the site going down is a strong possibility.

I know I know, this method is not opt for monitoring production and mission critical sites. There are so many free or paid tools, softwares, and apps are available in the market to watch and monitor such kind of sites. Those tools will immediately send alerts when your site is down. However, the above command is a quickest way to check your local or public website status within seconds.

Hope this helps. If you find this guide useful, please share it on your social networks and support OSTechNix.


Thanks for stopping by!

How can I benefit from this blog:

Have a Good day!!

You may also like...

2 Responses

  1. Dan Stromberg says:

    I wrote something along these lines years ago. It can be found here: .

    It (by default) e-mails you and gives you an X11 popup when a state changes; it can also page you if you have an email->pager gateway.

    For a website content change, you can:
    notify-when-up2 –delta ‘curl –silent | md5sum -‘
    That’ll make it memorize the md5 hash of on the first iteration, and check against that same md5 hash on each subsequent run until there’s a change.

    That way you don’t have to keep checking on a watch; you can just leave it running somewhere and mostly forget about it.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.