Commit dd191ca7 authored by 白秀江's avatar 白秀江

更新scan_no_ttl.sh

parent ffa05af0
#!/bin/bash
# redis ip
db_ip=127.0.0.1
# redis 端口
db_port=6379
# redis 密码
password=
# 第一次游标
cursor=0
# 每次迭代的数量
cnt=100
# 下一次游标
new_cursor=0
redis-cli -h $db_ip -p $db_port scan $cursor count $cnt > scan_tmp_result
new_cursor=`sed -n '1p' scan_tmp_result`
sed -n '2,$p' scan_tmp_result > scan_result
cat scan_result |while read line
do
ttl_result=`redis-cli -h $db_ip -p $db_port ttl $line` # 获取 key 过期时间
if [[ $ttl_result == -1 ]];then # 判断过期时间,-1 是不过期
echo $line >> no_ttl.log # 追加到指定文件
fi
done
while [[ $cursor != $new_cursor ]]
do
redis-cli -h $db_ip -p $db_port scan $new_cursor count $cnt > scan_tmp_result
new_cursor=`sed -n '1p' scan_tmp_result`
sed -n '2,$p' scan_tmp_result > scan_result
cat scan_result |while read line
do
ttl_result=`redis-cli -h $db_ip -p $db_port ttl $line`
if [[ $ttl_result == -1 ]];then
echo $line >> no_ttl.log
fi
done
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment