1,194
社区成员
发帖
与我相关
我的任务
分享
stringBuffer.append(dateFormat.format(new Date()))
.append("准备执行Shell命令 ").append(shellPathTime)
.append(" \r\n");
System.out.println("-------------->"+stringBuffer);
Process pid = null;
String[] cmd = { "/bin/sh", "-c", executeShell };
// 执行Shell命令
pid = Runtime.getRuntime().exec(cmd);
if (pid != null) {
stringBuffer.append("进程号:").append(pid.toString())
.append("\r\n");
// bufferedReader用于读取Shell的输出内容 bufferedReader = new
// BufferedReader(new InputStreamReader(pid.getInputStream()),
// 1024);
pid.waitFor();
} else {
stringBuffer.append("没有pid\r\n");
}