如何 nohup 从命令行生成的子进程?
我有一个有点复杂的问题来解释我遇到的问题:
- 我有一个长时间运行的 nohupped 进程,它将其 stderr 重定向到文件中。
- 但是,我使用子进程用时间戳标记 stderr。
- 不幸的是,上面提到的子进程没有 nohupped (我的错)!
- 现在,我如何以某种方式让这个子进程 nohupped 并保留 stderr 并在我注销后继续访问该文件。我必须注销服务器。
有问题的命令行看起来像这样:
$ nohup myscript.sh -op1 val1 -op2 val2 -op3 val3 >mystderr.txt 2> >(while read line; do echo "$(date): ${line}"; done > n100l1800g0.5.err ) < /dev/null &
上述标记 stderr 的技术是最近在 stackoverflow 上学到的。
预先感谢您提供任何线索。
I have a bit complex to explain issue that I have ran into:
- I have a long running nohupped process that redirects its stderr into a file.
- However, I use a subprocess to stamp the stderr with a timestamp.
- The above mentioned subprocess unfortunately is not nohupped (my bad)!
- Now, How do I get this subprocess somehow nohupped and get the stderr preserved and keep coming to the file even after I log out. I have to logout of the server.
The commandline in question looks something like this:
$ nohup myscript.sh -op1 val1 -op2 val2 -op3 val3 >mystderr.txt 2> >(while read line; do echo "$(date): ${line}"; done > n100l1800g0.5.err ) < /dev/null &
The above technique of stamping stderr is learned recently right here at stackoverflow.
Thanks in advance for any clue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的
nohup
手册页上写着nohup [ options ] command [arg ...]
。我记得在某个地方读过
nohup
不处理管道,我认为这就是你所拥有的。尝试将管道进程重新制作为接受参数的脚本,它应该可以工作。
The man page for the
nohup
I have saysnohup [ options ] command [arg ...]
.I remember reading someplace that
nohup
does not process pipelines, which I think is what you have.Try remaking your pipeline processes as a script that accept the arguments and it should work.
将命令放入 shell 脚本中并 nohup 该脚本。
所以如果 yourscript 包含 :
那么从命令行
Put your commands into a shell script and nohup the script.
so if yourscript contains :
then from the command line