2013-02-11 93 views
0

我必须在特定的tty上启动我的TextUI守护进程。为此目的,我启动它从一个脚本,像这样:$set_tty $launch_app,其中如何为openvt重定向stderr

  • set_tty="openvt -c1 -s -w"
  • launch_app="my_daemon 2>'$HOME'/logfile"

这样,我得到启动的命令看起来像openvt -c1 -s -w my_daemon 2>'$HOME'/logfile,会被重定向到指定的只记录openvt本身的stderr,但不记录我的守护进程。

它应该如何重定向openvt的被调用者stderr?

我尝试使用功能:

go() { my_daemon 2>"$HOME"/logfile; } 
openvt -c1 -s -w 

它不工作,opentty立即返回控制产卵什么。

我试图exec 2>>"$HOME"/logfile

我试图启动一个单独的脚本,与该功能。该脚本无法通过openvt运行,但如果使用相同参数手动启动脚本,则运行OK。

我错过了什么?

回答

1

一个可能的答案可能是一个封装外壳脚本,其内容将负责产生守护进程,并将stderr重定向到您选择的日志文件。

[[email protected] ~]$ cat test.sh 
#!/bin/bash 
echo "Testing openvt" > /tmp/openvt-example 

[[email protected] ~]$ sudo openvt -c7 -s -w /home/anew/test.sh 
[[email protected] ~]$ cat /tmp/openvt-example 
Testing openvt 
[[email protected] ~]$ 
+0

好的,我会在周四检查一下,当我回到那个系统时,我必须建立。我试过这个,一定是搞砸了。 谢谢! – gluk47 2013-02-11 18:42:40

+0

谢谢。我忘记了'chmod + x'我的脚本。 – gluk47 2013-02-14 13:26:46