Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1375168
  • 博文数量: 77
  • 博客积分: 2104
  • 博客等级: 大尉
  • 技术积分: 2322
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-19 13:21
个人简介

关注于系统高可用、网站架构

文章分类

全部博文(77)

文章存档

2018年(1)

2017年(1)

2015年(4)

2014年(8)

2013年(4)

2012年(12)

2011年(17)

2010年(30)

分类: Java

2011-11-30 15:03:30

经常碰到运营部门人要清缓存,而缓存一直存在问题,老在电脑面前处理也不是个办法,想了个方法,通过访问一个jsp页面自动清缓存

<%@ page language="java" import="java.io.*" pageEncoding="UTF-8"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme() + "://"

+ request.getServerName() + ":" + request.getServerPort()

+ path + "/";

%>

shell

<%

String cmds = "monitor.sh";

try {

Process process;

process = Runtime.getRuntime().exec("sh /opt/test.sh");

InputStreamReader ir = new InputStreamReader(process

.getInputStream());

LineNumberReader input = new LineNumberReader(ir);

String line;

process.waitFor();

while ((line = input.readLine()) != null){

out.print(line);

out.print("
");

}

if(input!=null){

input.close();

}

} catch (Exception e) {

e.printStackTrace();

}

%>

 

test.sh 脚本内容

echo 'flush_all' | nc 192.168.10.73 11211

将该脚本放到jboss/server/default/deploy/jboss-web.deployer/ROOT.war/ 下就可以访问了

 

阅读(4691) | 评论(2) | 转发(2) |
0

上一篇:shell调用技巧

下一篇:keepalived 安装

给主人留下些什么吧!~~

校长的马夹2011-12-02 00:16:04

通过访问jsp页面自动清缓存真不错!

重返人生2011-12-01 00:00:17

学习了