nohup命令不在厨师资源中工作(nohup command not working in chef resources)

编程入门 行业动态 更新时间:2024-10-25 04:24:12
nohup命令不在厨师资源中工作(nohup command not working in chef resources)

我正在尝试执行

>nohup.out nohup ./example.sh &

它来自我的main.sh文件。 我从Chef的bash资源调用main.sh。 但是,当我运行chef-client时会抛出STDERR。 不应该去nohup.out吗?

I am trying to execute

>nohup.out nohup ./example.sh &

which comes under my main.sh file. I am calling the main.sh from my bash resource in Chef. However, the STDERR is thrown when I run the chef-client. Shouldn't it go to nohup.out ?

最满意答案

从nohup手册 :

如果标准输入是终端,则从/ dev / null重定向。 如果standard> output是终端,则在可能的情况下将输出附加到'nohup.out',否则输入'$ HOME / nohup.out'。 如果标准错误是终端,则将其重定向到标准输出。

因此,要将stderr重定向到nohup.out,首先应将其重定向到stdout:

nohup 2>&1 ./example.sh &

From nohup manual:

If standard input is a terminal, redirect it from /dev/null. If standard >output is a terminal, append output to 'nohup.out' if possible, >'$HOME/nohup.out' otherwise. If standard error is a terminal, redirect it >to standard output.

So to have stderr redirected to nohup.out you should first redirect it to stdout:

nohup 2>&1 ./example.sh &

更多推荐

本文发布于:2023-08-04 12:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1416453.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:厨师   命令   工作   资源   nohup

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!