ProcessBuilder java.io.IOException: Cannot run program error=2, No such file or directory
程序员文章站
2022-05-12 15:01:26
...
通过java ProcessBuilder执行如下命令,
String killCommand = String.format("ps -ef|grep java|grep 'kafka_sink_partitition_test_2019_0730/conf/'|awk '{print $2}'|xargs kill -9",taskName);
try {
LOG.info(String.format("starting to execute kill command: %s",killCommand));
ProcessBuilder pb = new ProcessBuilder(killCommand);
Process process = pb.start();
int errCode = process.waitFor();
LOG.info(String.format("finished kill local driver task: %s code: %s",taskName,errCode ));
} catch (Exception e) {
LOG.warn(String.format("kill local driver task: %s error: ",taskName),e);
}
报错信息
java.io.IOException: Cannot run program "ps -ef|grep java|grep 'kafka_sink_partitition_test_2019_0730/conf/'|awk '{print $2}'|xargs kill -9": error=2, No such file or directory
这种方式执行pipe命令会有问题Using Java ProcessBuilder to Execute a Piped Command
改为返回code137 应该是128+9
ProcessBuilder pb = new ProcessBuilder("/bin/sh", "-c",killCommand);
上一篇: PHP的中问验证码_php实例
下一篇: CCF191203化学方程式满分
推荐阅读
-
Cannot run program "/usr/local/android-sdk-linux/build-tools/23.0.2/aapt": error=2, No such file or
-
Pycharm:Error: Cannot run programError: Cannot run program......CreateProcesss error=2
-
Cannot run program "/usr/local/android-sdk-linux/build-tools/23.0.2/aapt": error=2, No such file or
-
Android:java.io.IOException: Cannot run program "/system/xbin/su": error=13, Permission denied
-
java.io.IOException: Cannot run program “/usr/local/python3“: error=13, 权限不够
-
Cannot run program \"cd\": error=2, No such file or directory
-
Spark报错java.io.IOException: Cannot run program "python": CreateProcess error=2, 系统找不到指定的文件
-
Android -Cannot run program "XXX/sdk/tools/emulator": error=2, No such file or directory
-
求助:使用oppenoffice转换文件格式时报错Cannot run program "C:\Program": CreateProcess error=2, 系统找不到指定的文件
-
ProcessBuilder java.io.IOException: Cannot run program error=2, No such file or directory