nohup 命令在厨师资源中不起作用

nohup command not working in chef resources

我正在尝试执行

>nohup.out
nohup ./example.sh &

在我的 main.sh 文件下。我正在从 Chef 中的 bash 资源调用 main.sh。但是,当我 运行 主厨客户端时抛出 STDERR。它不应该去 nohup.out 吗?

来自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.

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

nohup 2>&1 ./example.sh &