首页 新闻 赞助 找找看

怎么获取linux脚本的执行状态

0
悬赏园豆:20 [已解决问题] 解决于 2019-10-10 15:30

我在Java,使用Runtime,执行Linux命令。
比如执行:“hive -f 'hivetest.sh'”,hivetest.sh是Linux上面的一个脚本(关于hive的建表、load数据等等。)
我的问题是:怎么获取这个脚本的执行状态(脚本中的命令是成功了还是失败了)。

promax的主页 promax | 初学一级 | 园豆:186
提问于:2019-08-06 15:04
< >
分享
最佳答案
0

public static void execute(String shellString) {
try {
Process process = Runtime.getRuntime().exec(shellString);
int exitValue = process.waitFor();
if (0 != exitValue) {
log.error("call shell failed. error code is :" + exitValue);
}
} catch (Throwable e) {
log.error("call shell failed. " + e);
}
}

promax | 初学一级 |园豆:186 | 2019-08-06 17:23
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册