Posted on 2010-12-03 14:35
S.l.e!ep.¢% 閱讀(1069)
評(píng)論(0) 編輯 收藏 引用 所屬分類:
Unix
在shell中,文件描述符通常是:STDIN標(biāo)準(zhǔn)輸入,STDOUT標(biāo)準(zhǔn)輸出,STDERR標(biāo)準(zhǔn)錯(cuò)誤輸出,即:0,1,2,
例子:nohup abc.sh > nohup.log 2>&1 &
其中2>&1? 指將STDERR重定向到前面標(biāo)準(zhǔn)輸出定向到的同名文件中,即&1就是nohup.log
那么結(jié)果就是當(dāng)執(zhí)行的命令發(fā)生標(biāo)準(zhǔn)錯(cuò)誤,那么這個(gè)錯(cuò)誤也會(huì)輸出到你指定的輸出文件中?
nohup把a(bǔ)bc.sh的輸出重定向到文件nohup.log 同時(shí)出現(xiàn)錯(cuò)誤也輸出到nohup.log ,然后后臺(tái)執(zhí)行。
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