| 
					
				 | 
			
			
				@@ -22,14 +22,20 @@ public class LinuxCommand { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public static void exec(String cmd) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Process process = Runtime.getRuntime().exec(cmd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        log.info("要执行命令了哟:{}", cmd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        print(process); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("要执行命令了哟:{}", cmd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            print(process); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        int code = process.waitFor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        log.info("{}命令,执行状态{}", cmd, code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int code = process.waitFor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("{}命令,执行状态{}", cmd, code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (code != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new Exception("执行命令出错啦!" + cmd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (code != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new Exception("执行命令出错啦!" + cmd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw e; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } finally { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            process.destroy(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -40,15 +46,20 @@ public class LinuxCommand { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public static void exec(String[] cmd) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Process process = Runtime.getRuntime().exec(cmd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("要执行命令了哟:{}", Arrays.toString(cmd)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            print(process); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        log.info("要执行命令了哟:{}", Arrays.toString(cmd)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        print(process); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        int code = process.waitFor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        log.info("{}命令,执行状态{}", cmd, code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int code = process.waitFor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("{}命令,执行状态{}", cmd, code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (code != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new Exception("执行命令出错啦!" + cmd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (code != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new Exception("执行命令出错啦!" + cmd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw e; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } finally { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            process.destroy(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -61,18 +72,24 @@ public class LinuxCommand { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @throws Exception 异常说明 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public static void mysqlExport(List<String> commands, String path) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.info("要执行命令了哟:{}", Arrays.toString(commands.toArray())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ProcessBuilder processBuilder = new ProcessBuilder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         processBuilder.command(commands); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         processBuilder.redirectOutput(new File(path)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Process process = processBuilder.start(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        print(process); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        int code = process.waitFor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        log.info("mysql备份执行状态:{}", code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (code != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new Exception("执行mysql备份命令出错啦!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Process process = processBuilder.start(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            print(process); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int code = process.waitFor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("mysql备份执行状态:{}", code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (code != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new Exception("执行mysql备份命令出错啦!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw e; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } finally { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            process.destroy(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -86,13 +103,18 @@ public class LinuxCommand { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.info("要执行命令了哟:{}", Arrays.toString(commands.toArray())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ProcessBuilder processBuilder = new ProcessBuilder(commands); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Process process = processBuilder.start(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            print(process); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        print(process); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        int code = process.waitFor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        log.info("命令执行状态:{}", code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (code != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new Exception("执行命令出错啦!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int code = process.waitFor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("命令执行状态:{}", code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (code != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new Exception("执行命令出错啦!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw e; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } finally { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            process.destroy(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -110,13 +132,17 @@ public class LinuxCommand { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         processBuilder.directory(new File(dir)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Process process = processBuilder.start(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        print(process); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        int code = process.waitFor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        log.info("脚本执行状态:{}", code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (code != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new Exception("执行脚本出错啦!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            print(process); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int code = process.waitFor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("脚本执行状态:{}", code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (code != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new Exception("执行脚本出错啦!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw e; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } finally { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            process.destroy(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |