【发布时间】:2016-12-22 14:24:12
【问题描述】:
我试图在后台运行一个在我的函数/进程结束时不会终止的 shell 脚本。然而,似乎尽管 nohup,当 java 线程结束时。脚本也是如此。
下面是示例代码。
///
/// Tries to run a script in the background
///
try {
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("nohup sh ./runner.sh > output.txt &", new String[] {}, wrkDir);
// pr.waitFor(); // Intentionally not using
} catch(Exception e) {
throw new RuntimeException(e);
}
【问题讨论】:
标签: java multithreading shell