1
- Create dir
logs
(for outputted logs) - Create a script
IsTheServerUp.bash
- Write a script to check if the server is up
- Log(
echo
) the outcome to the file - Use
curl
command to check the server - 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
- If status
- Include status code and the date/time stamp.
- Log outputted message to
mylog.log
- Use
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
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.800Perhaps 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.750Thank 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