当Java运行时执行shell脚本时,nohup.out文件将在何处创建?

当Java运行时执行shell脚本时,nohup.out文件将在何处创建?,java,linux,unix,runtime,nohup,Java,Linux,Unix,Runtime,Nohup,当我通过java Runtime.exec()执行shell脚本时,在哪里可以找到nohup.out文件 String command=“nohup ksh/home/xyz/script.ksh&” Runtime rtime=Runtime.getRuntime() rtime.exec(命令) nohup仅将连接到终端的输出写入文件。当您通过exec调用它时,情况并非如此,因此输出将写入子进程的stdout(您可以通过getInputStream获得)。无nohup.out将在任何位置创建

当我通过java Runtime.exec()执行shell脚本时,在哪里可以找到nohup.out文件

String command=“nohup ksh/home/xyz/script.ksh&”

Runtime rtime=Runtime.getRuntime()


rtime.exec(命令)

nohup
仅将连接到终端的输出写入文件。当您通过
exec
调用它时,情况并非如此,因此输出将写入子进程的stdout(您可以通过
getInputStream
获得)。无
nohup.out将在任何位置创建。

“&
将不起作用。该字符仅为shell所理解,即使您正在执行shell,当您使用Runtime.exec时,也不会在shell中执行命令。好消息是,您不需要
“&”
;进程已经在后台运行,即使没有该字符。那么您的意思是说Runtime.exec()既不生成nohup.out,也不将nohup.out重定向到某个文件?请尝试{String command=“nohup ksh/home/xyz/script.ksh&”ProcessBuilder pb=new ProcessBuilder(command);final process p=pb.start();BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream());字符串行;while((line=br.readLine())!=null){System.out.println(line);}}}catch(Exception ex){System.out.println(ex);}String command=“nohup ksh/home/xyz/script.ksh&”;ProcessBuilder=新的ProcessBuilder(strCommand);redirectOutput(新文件(“/home/heena/Desktop/megha/redirectOutput.log”);重定向错误(新文件(“/home/heena/Desktop/megha/redirectOutputer.log”);进程p=builder.start();Runtime=Runtime.getRuntime();Process=runtime.exec(args);InputStream=process.getInputStream();InputStreamReader isr=新的InputStreamReader(is);BufferedReader br=新的BufferedReader(isr);弦线;System.out.printf(“运行%s的输出为:”,Arrays.toString(args));while((line=br.readLine())!=null){System.out.println(line);}