我正在尝试执行
>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 &更多推荐
发布评论