|
@@ -24,7 +24,9 @@ public class ShellUtil {
|
|
|
try {
|
|
|
// 执行命令, 返回一个子进程对象(命令在子进程中执行)
|
|
|
log.info("执行cmd:{}",cmd);
|
|
|
- process = Runtime.getRuntime().exec(cmd);
|
|
|
+ String[] cmd2 = new String[]{"/bin/sh", "-c", cmd};
|
|
|
+
|
|
|
+ process = Runtime.getRuntime().exec(cmd2);
|
|
|
// 获取命令执行结果, 有两个结果: 正常的输出 和 错误的输出(PS: 子进程的输出就是主进程的输入)
|
|
|
//处理InputStream的线程
|
|
|
threadRun(process);
|
|
@@ -115,10 +117,7 @@ public class ShellUtil {
|
|
|
|
|
|
public static void zip(String dataPath, String zipPath) {
|
|
|
log.info("打包zip开始");
|
|
|
- if(!new File(zipPath).getParentFile().exists()){
|
|
|
- return;
|
|
|
- }
|
|
|
- String command = "zip -r " + zipPath + " " + dataPath;
|
|
|
+ String command ="cd " + dataPath + " && zip -r " + zipPath + " * " ;
|
|
|
execCmd(command);
|
|
|
log.info("解压zip完毕:" + command);
|
|
|
}
|