Ste*_*eve 1 unix bash sed pipe nohup
在我的服务器上nohup sleep 1 > nohup.out &没有提供帮助信息.好.
在我的笔记本电脑上运行相同的命令,我得到:nohup: ignoring input and redirecting stderr to stdout.虽然命令仍然正常运行并完成,但我不明白为什么在我的两台机器之间报告此消息存在差异.幸运的是,我可以通过简单地将stderr和stdout重定向到文件来解决我的笔记本电脑上的这个问题:nohup sleep 1 &> nohup.out &
所以....我想要做的是在我的笔记本电脑上实现一个更有用的命令:
以下在我的服务器上工作正常,并且没有报告消息:
nohup ls -1 *.txt | sed -e "s%\(.*\)%/home/user/scripts/script.pl -find \1 %" | sh > nohup.out &
这行代码"nohups"将一个文件管道列表导入到sed中,它们script.pl连续运行并在shell中执行.script.pl将数据打印到多个文件,并将一些信息打印到stdout.我通过将其写入名为的文件来捕获此信息nohup.out
现在,当我在笔记本电脑上运行这个单行时,我明白了nohup: ignoring input and redirecting stderr to stdout.这是预期的(但由于我不知道的原因).但是当我修改行重定向stderr和stdout时:
nohup ls -1 *.txt | sed -e "s%\(.*\)%/home/user/scripts/script.pl -find \1 %" | sh &> nohup.out &
我仍然得到消息 nohup: ignoring input and redirecting stderr to stdout
如何修复我的单行程序,使其在我的笔记本电脑上运行而不会显示消息?
pot*_*ong 10
我这可能适合你:
nohup ls -1 *.txt 2>/dev/null | .....
Run Code Online (Sandbox Code Playgroud)
原因是nohup发出警告信息stderr,所以stderr无处可2>/dev/null去.