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>