码迷,mamicode.com
首页 > 其他好文 > 详细

Redis批量删除脚本

时间:2019-01-21 13:57:36      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:cti   klist   .sh   red   cli   lin   pac   bin   UNC   

#! /bin/bash
 
# sh redis_del_batch.sh . localhost 7000 redis7000 *blacklist*
 
function redis_del(){
local host port key_pattern
 
echo "begin delete redis key , host :" $2 ", port :" $3 ", key pattern :" $5 "......"
 
host=$2
port=$3
passwd=$4
key_pattern=$5
total_sum=0
 
$1/redis-cli -h ${host} -p ${port} -a ${passwd} --scan --pattern ${key_pattern} | while read LINE
 
do
echo "delete key : " $LINE
$1/redis-cli -h ${host} -p ${port} -a ${passwd} del $LINE
total_sum=$(($total_sum+1))
echo "del key num : " $total_sum
done
 
echo "finish delete redis key , host :" $2 ", port :" $3 ", key pattern :" $5 "......"
}
 
redis_del $1 $2 $3 $4 $5

Redis批量删除脚本

标签:cti   klist   .sh   red   cli   lin   pac   bin   UNC   

原文地址:https://www.cnblogs.com/gjb724332682/p/10298018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!