Created
September 13, 2023 10:25
-
-
Save clasense4/9f626df448221f955a398e7a17b03ba5 to your computer and use it in GitHub Desktop.
Hit Redis endlessly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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