- 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
curl
is supposed to do. I suggest you review the manual (man curl
) to understand the tool you are trying to use.