1、将命令写在文件中

数据量比较大的话,建议用程序去生成文件。例如:

List<String> planIdList = planDao.findAll().parallelStream().map(PlanModel::getId).map(String::valueOf).collect(Collectors.toList());
BufferedWriter br = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("/Users/chengjiansheng/Desktop/command.txt")));
for (String planId : planIdList) {
    br.write("SADD PLAN_UNSYNC_S " + planId + "\r\n");
}
br.flush();
br.close();

生成的文件可能是这样的:

脚本批量执行Redis命令

接下来,命令行执行

cat command.txt | redis-cli -h 127.0.0.1 -p 6379 -a 123456 --pipe

脚本批量执行Redis命令

脚本批量执行Redis命令

这个例子比较简单,可以这么做,如果命令比较多的话可以写成shell脚本

脚本批量执行Redis命令

2、grep命令

grep "NullPointerException" access.log | wc -l
grep "com\.cjs\.babyplan\.controller\.QuestionController.*118795924" access.2019-09-17.log

脚本批量执行Redis命令

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-12-23
  • 2021-12-05
  • 2021-10-31
相关资源
相似解决方案