Bash script to test websites with curl
Posted On April 3, 2018
We will look at very basic script which will make sure multiple websites are up and running. This is very basic script that utilities power of Linux tool called curl. Curl is well know tool used to automate url related tasks and much more.
The basic script will use variable called $LIST_OF_WEBSITES which will contain list of websites we need to test. In our example
Then we will create a loop that will report error for any curl output from $? that is not 0
for i in $LIST_OF_WEBSITES; do
curl -Is http://$i/ > /dev/null
if [ $? -ne 0 ]
echo -e "$i \e[91m [DOWN]\e[0m"
echo -e "$i \e[92m [OK]\e[0m"