Selvakumar Ponnusamy
Selvakumar Ponnusamy

Reputation: 5563

Check Whether a Web Application is Up or Not

I would like to write a script to check whethere the application is up or not using unix shell scripts.

From googling I found a script wget -O /dev/null -q http://mysite.com, But not sure how this works. Can someone please explain. It will be helpful for me.

Upvotes: 1

Views: 3274

Answers (2)

Michael Dillon
Michael Dillon

Reputation: 32392

  1. Run the wget command
  2. the -O option tells where to put the data that is retrieved
  3. /dev/null is a special UNIX file that is always empty. In other words the data is discarded.
  4. -q means quiet. Normally wget prints lots of info telling its progress in downloading the data so we turn that bit off.
  5. http://mysite.com is the URL of the exact web page that you want to retrieve.

Many programmers create a special page for this purpose that is short, and contains status data. In that case, do not discard it but save it to a log file by replacing -O /dev/null with -a mysite.log.

Upvotes: 4

Shiplu Mokaddim
Shiplu Mokaddim

Reputation: 57690

Check whether you can connect to your web server.

  1. Connect to the port where you web server
  2. If it connects properly your web server is up otherwise down.
  3. You can check farther. (e.g. if index page is proper)

See this shell script.

if wget -O /dev/null -q http://shiplu.mokadd.im; 
then 
    echo Site is up
else 
    echo Site is down
fi

Upvotes: 2

Related Questions