Skip to content

Instantly share code, notes, and snippets.

@clasense4
Created September 13, 2023 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clasense4/9f626df448221f955a398e7a17b03ba5 to your computer and use it in GitHub Desktop.
Save clasense4/9f626df448221f955a398e7a17b03ba5 to your computer and use it in GitHub Desktop.
Hit Redis endlessly
#!/bin/bash
# Check if Redis CLI is installed
if ! command -v redis-cli &> /dev/null
then
echo "redis-cli could not be found, please install it first"
exit
fi
# Infinite loop to ping Redis
while true; do
RESPONSE=$(redis-cli -h localhost ping)
if [ "$RESPONSE" == "PONG" ]; then
TIMESTAMP=$(date +"%Y-%m-%d %T")
echo "PONG received at $TIMESTAMP"
else
echo "Unexpected response: $RESPONSE"
fi
sleep 1 # Optional, to reduce the frequency of pings
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment