2017-07-14 42 views

回答

6

您可以完全在水晶做到这一点,而不使用的Process.newoutput选项生成一个壳。

File.open("app_name.log", "a") do |file| 
    Process.new("app_name", output: file) 
end 
+0

事实上,这个答案给了我我想要的。有了shell,当我尝试获取我的进程的'pid'时,我得到了记录器进程的'pid'。再次感谢您的回答。 – nobilik

+0

@nobilik请将其标记为接受的答案 – RX14

3

Process.new默认情况下直接执行给定的命令而不使用shell,因此Shell扩展如管道不起作用。但它接受参数shell,如果设置为true,则该参数执行命令/bin/sh

Process.new("app_name >> app_name.log", shell: true) 
相关问题