以下代码块实现的主要功能是:
通过脚本文件运行,将每隔一秒将yc5这个值加1,机器为172.17.69.126,端口为6379
#!/bin/bash
while :
do
YC5=`echo "HGET CAN01 yc5" | redis-cli -h '172.17.69.126' -p 6379`
echo $YC5
if [ "$YC5" -ge "1000" ]; then
echo "HSET CAN01 yc5 0" | redis-cli -h '172.17.69.126' -p 6379
else
echo "HINCRBYFLOAT CAN01 yc5 1" | redis-cli -h '172.17.69.126' -p 6379 > /tmp/allkeys.txt
fi
#echo "Hit [ CTRL+C ] to stop!"
sleep 1
done
网友评论