nohup 输出重定向

来源:互联网 发布:mysql union 用法 编辑:程序博客网 时间:2024/06/05 09:49

在shell中,文件描述符通常是:STDIN标准输入,STDOUT标准输出,STDERR标准错误输出,即:0,1,2,

例子:nohup abc.sh > nohup.log 2>&1 &

其中2>&1 指将STDERR重定向到前面标准输出定向到的同名文件中,即&1就是nohup.log

那么结果就是当执行的命令发生标准错误,那么这个错误也会输出到你指定的输出文件中

nohup把abc.sh的输出重定向到文件nohup.log 同时出现错误也输出到nohup.log ,然后后台执行。
There are two formats for redirecting standard output and standard error:
&>word
and

&word
Of the two forms, the first is preferred. This is semantically equivalent to
word 2>&1

原创粉丝点击