Skip to content

Instantly share code, notes, and snippets.

@sweetmandm
sweetmandm / uptimemonitor.sh
Last active July 26, 2023 07:01
Cron job to monitor websites and send an email if the website is down.
#! /bin/sh
# A script to monitor uptime of websites,
# and notify by email if a website is down.
SITES="ADD COMMA-SEPARATED WEBSITES HERE"
EMAILS="ADD COMMA-SEPARATED EMAILS HERE"
for SITE in $(echo $SITES | tr "," " "); do
if [ ! -z "${SITE}" ]; then
RESPONSE=$(curl -s --head $SITE)
if echo $RESPONSE | grep "200 OK" > /dev/null