批量执行redis命令

来源:互联网 发布:算法时间复杂性分析 编辑:程序博客网 时间:2024/06/05 00:24

<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">首先将要执行的命令放在一个文本文件中(redis-commons.txt),一条命令一行(命令行的第一个字符最好是空格,因为有可能会出命令行第一个字符丢失)</span>

 select 1 del "test:2" del "test:1" del "test:3" del "test:4"

编辑脚本文件(redis-commons-run.sh)

#!/bin/shhost=$1port=$2password=$3cat /opt/redis-commons.txt | /opt/redis-3.0.4/src/redis-cli -h $host -p $port -a $password --pipe

运行脚本:

# ./redis-commons-run.sh localhost 6379 sv8G4V8888
参数解释:

localhost  --> IP地址

6379 --> 端口

sv8G4V8888 --> 密码


转至http://blog.csdn.net/afeiluo/article/details/47316409


0 0
原创粉丝点击