Check to see if server is up

1

  1. Create dir logs (for outputted logs)
  2. Create a script IsTheServerUp.bash
  3. Write a script to check if the server is up
  4. Log(echo) the outcome to the file
  5. Use curl command to check the server
  6. Use rules above to write your bash
    • Use curl to request a webpage from a server
    • Provide the --output/dev/null option + argument to suppress output.
    • Check return status ($?)
      • If status 0(success)
      • If not (0) error message
    • Include status code and the date/time stamp.
    • Log outputted message to mylog.log

My current code which doesn't work:

#! bin/bash
if curl -s --head  --request GET http://opx.com/opx/version | grep "200 OK"    > /dev/null && curl -s --head --request GET http://oss.com/version | grep "200   OK" > /dev/null;
exit 0

CrazyGal

Posted 2017-03-26T23:18:24.700

Reputation: 21

Which bit doesn't work? What is the error? – Michael Frank – 2017-03-26T23:24:19.443

when I type curl "http://.." It just outputs a list Of HTML and CSS for that website – CrazyGal – 2017-03-26T23:26:01.807

That's what curl is supposed to do. I suggest you review the manual (man curl) to understand the tool you are trying to use. – Michael Frank – 2017-03-26T23:35:45.800

Perhaps How to check whether a command such as curl completed without error? or How to stop shell script if curl failed will be of help to you.

– moonpoint – 2017-03-27T01:14:48.750

Thank you for your comments.. I'll try to re edit this question because I made some changes. – CrazyGal – 2017-03-27T14:01:21.040

This looks like a school assignment...reading man pages for the tools you use is the way to go. – simlev – 2017-03-27T16:05:59.230

No answers