public static String getLinuxPID(String command) {
BufferedReader reader = null;
try {
//显示所有进程
Process process = Runtime.getRuntime().exec("ps -ef");
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
if (line.contains(command)) {
String[] strs = line.split("\\s+");
return strs[1];
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
}
}
}
return null;
}
| 修改日期 | 修改人 | 备注 |
| 2020-07-09 09:45:29[当前版本] | 倪嗣成 | 创建版本 |
| 2020-07-09 09:44:46 | 倪嗣成 | 创建版本 |
| 2020-07-09 09:43:57 | 倪嗣成 | 创建版本 |
| 2020-07-09 09:41:07 | 倪嗣成 | 创建版本 |