A Bash Script to check the website availability?

A Bash Script to check the website availability?

Create the script.
vi my_web_site_status.sh
#!/bin/bash
#Author: manas.tri@gmail.com
status_code=`curl -I -s -L manastri.blogspot.com | grep "HTTP"`
echo `date` >> /tmp/my_web_status
echo $status_code >> /tmp/my_web_status


make the script executable.
chmod  +x my_web_site_status.sh

Test: 
Now run the script.
[testserver:/]# bash -x my_web_site_status.sh
++ curl -I -s -L manastri.blogspot.com
++ grep HTTP
' status_code='HTTP/1.1 200 OK
++ date
+ echo Wed Sep 26 07:27:18 CEST 2018
+ echo HTTP/1.1 200 $'OK\r'
[testserver:/]# cat /tmp/my_web_status
Wed Sep 26 07:27:09 CEST 2018
HTTP/1.1 200 OK
Wed Sep 26 07:27:17 CEST 2018
HTTP/1.1 200 OK
Wed Sep 26 07:27:18 CEST 2018
HTTP/1.1 200 OK
[testserver:/]#





0 Comments