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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.