Timer定时通过Runtime的exec方法调用命令“cmd exp..” 后,任务管理器不停的出现“Java.exe”和“cmd.exe”进程
两个类分别是Cmd_Exp和Task:
public class Cmd_Exp {
public static void main(String[] args) {
Timer timer = new Timer();
timer.schedule(new Task(), 1000, 60*1000*60*24);
}
}
public class Task extends TimerTask {
...
...
Runtime tr = Runtime.getRuntime();
String mark = null;
String dt = null;
String nam = null;
public void run() {
try {
loadConfig();
} catch (Exception e1) {
e1.printStackTrace();
}
Date today = new Date(new Date().getTime() - 24 * 60 * 60 * 1000);
SimpleDateFormat ss = new SimpleDateFormat(dateFormat);
dt = ss.format(today);
try {
tr.exec("cmd /c exp " + user + "/" + password + "@" + dbID + " file=" + filePath + partitionPrefix + dt + artitionSuffix + ".dmp tables=" + tableName + ":" + partitionPrefix + dt + partitionSuffix); } catch (IOException e) {
e.printStackTrace();
}
mark = "表分区正在导出";
System.out.println(mark);
}
...
...
}
exec命令中的一些参数是配置文件导入进去的。
这个程序在eclipse里运行没有问题,封装成jar包导出,编成bat执行后,任务管理器就不停的产生java.exe 和cmd.exe进程,
不知道原因!!