标签:cep put kill -9 i++ process pid read ++ time
ProcessBuilder builder = new ProcessBuilder(命令,参数,参数。。。);
Process process = builder.start();
br = new BufferedReader(new InputStreamReader(process.getInputStream()));
可以从br中读取日志信息
根据ID杀掉进程
String os = System.getProperty("os.name");
try {
if (os != null && os.startsWith("Windows")){
for (int i = 0; i < pid.size(); i++) {
Runtime.getRuntime().exec("Taskkill /f /IM " + pid.get(i));
}
}else{
for (int i = 0; i < pid.size(); i++) {
System.out.println("关闭linux进程");
String[] cmd ={"sh","-c","kill -9 "+pid.get(i)};
Runtime.getRuntime().exec(cmd);
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
标签:cep put kill -9 i++ process pid read ++ time
原文地址:http://www.cnblogs.com/ginkgo5198/p/7069112.html