sh /usr/local/tomcat6/bin/startup.sh
:wq
chmod u+x ./restart.sh //给矛sh文件可执行权限
./restart.sh
runsh.jsp
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%
Runtime rt = Runtime.getRuntime();
rt.exec("/usr/local/tomcat6/bin/restart.sh");
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>远程重启tomcat</title>
</head>
<body>
远程重启tomcat命令执行,请稍候!
当前状态:<span id="flag"></span>
<script type="text/javascript">
function ping(){
$.ajax({
url: 'http://目标网址',
type: 'GET',
complete: function(response) {
if(response.status == 200) {
$("#flag").html('<a href="/">重启成功!</a>');
clearInterval(gtime);
} else {
$("#flag").html('启动中,请稍候!'+response.status);
}
}
});
}
var gtime;
$(document).ready(function(){
gtime = setInterval(ping, 2000);//每隔2秒自动扫描网站是否可用
});
</script>
</body>
</html>