Skip to content

Instantly share code, notes, and snippets.

@redpop
Last active August 16, 2023 19:09
Show Gist options
  • Save redpop/0de0afae37c0ff8b16afd1eeffc70f4d to your computer and use it in GitHub Desktop.
Save redpop/0de0afae37c0ff8b16afd1eeffc70f4d to your computer and use it in GitHub Desktop.
Ping Google every 60 seconds
#!/bin/bash
GREEN='\033[1;32m'
RED='\033[1;31m'
NC='\033[0m' # No Color
while true; do
if ping -c 1 google.com &> /dev/null; then
echo -e "${GREEN}$(date): Internet connection is up${NC}"
else
echo -e "${RED}$(date): Internet connection is down${NC}"
fi
sleep 60 # Wait for 60 seconds before testing again
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment