Network PING (bash script)

The Universal Linux Society
1 min readMar 27, 2024

--

We have added a new script to our github repo “network ping” :

Network Ping

This bash script allows users to check the availability of a website or server by providing its URL.

In case of unavailability, the script sends an email notification to alert the user.

The script has been written to be easily configured into a cron job for automated periodic checks. Below you can see the code,it can easily be modified by the user.

#! /bin/bash
read -p "Enter the server or website address to check: " HOST
read -p "Enter the email address to receive alerts: " EMAIL
ping -c 4 "$HOST" > /dev/null
if [ $? -ne 0 ]; then
echo "Connection to $HOST is down" | mail -s "Network ALERT" "$EMAIL"
else
echo "Connection to $HOST is up"
fi

#linux #network #networking #ping #sysadmin #unix #github

--

--

The Universal Linux Society

Uniting Linux users worldwide in the pursuit of open-source knowledge, and progression.